jaguar_mongo

MongoDB extension for Jaguar

Example of using MongoDb interceptor

@Api(path: '/api')
class MongoDbExampleApi extends _$JaguarMongoDbExampleApi {
  /// NOTE: Example of using MongoDb interceptor in basic route
  @Post(path: '/')
  // NOTE: This is how MongoDb interceptor is wrapped
  // around a route.
  // Now other interceptors and route handler methods can
  // request injection of opened connection using `@Input(MongoDb)`
  @WrapMongoDb('mongodb://localhost:27017/test')
  Future<String> mongoTest(
      // NOTE: This is how the opened mongodb connection is injected
      // into routes
      @Input(MongoDb) Db db) async {
    return "ok";
  }
}

Libraries

jaguar_mongo