2024-06-23 03:15:41 +00:00
|
|
|
import 'package:angel3_container/mirrors.dart';
|
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 {
|
2024-06-23 03:15:41 +00:00
|
|
|
var app = Angel(reflector: MirrorsReflector());
|
2024-07-02 16:13:02 +00:00
|
|
|
var db = Db('mongodb://localhost:27017/testDB');
|
2018-10-18 23:01:58 +00:00
|
|
|
await db.open();
|
2024-07-04 16:04:58 +00:00
|
|
|
await db.authenticate("root", "Qwerty", authDb: "admin");
|
2018-10-18 23:01:58 +00:00
|
|
|
|
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
|
|
|
});
|
|
|
|
}
|