platform/packages/mongo/example/example.dart

16 lines
425 B
Dart
Raw Normal View History

2018-10-18 23:01:58 +00:00
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_mongo/angel_mongo.dart';
import 'package:mongo_dart/mongo_dart.dart';
2021-06-18 10:17:13 +00:00
void main() async {
var app = Angel();
var db = Db('mongodb://localhost:27017/local');
2018-10-18 23:01:58 +00:00
await db.open();
2021-06-18 10:17:13 +00:00
var service = app.use('/api/users', MongoService(db.collection('users')));
2018-10-18 23:01:58 +00:00
service.afterCreated.listen((event) {
2021-06-18 10:17:13 +00:00
print('New user: ${event.result}');
2018-10-18 23:01:58 +00:00
});
}