platform/packages/mongo/example/example.dart

16 lines
429 B
Dart
Raw Normal View History

2021-06-18 11:10:38 +00:00
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_mongo/angel3_mongo.dart';
2018-10-18 23:01:58 +00:00
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
});
}