platform/packages/mongo/example/example.dart
2024-10-12 18:45:27 -07:00

17 lines
580 B
Dart

import 'package:protevus_container/mirrors.dart';
import 'package:protevus_framework/protevus_framework.dart';
import 'package:protevus_mongo/protevus_mongo.dart';
import 'package:mongo_dart/mongo_dart.dart';
void main() async {
var app = Protevus(reflector: MirrorsReflector());
var db = Db('mongodb://localhost:27017/testDB');
await db.open();
await db.authenticate("root", "Qwerty", authDb: "admin");
var service = app.use('/api/users', MongoService(db.collection('users')));
service.afterCreated.listen((event) {
print('New user: ${event.result}');
});
}