style_mongo 1.0.0 copy "style_mongo: ^1.0.0" to clipboard
style_mongo: ^1.0.0 copied to clipboard

MongoDb DataAccess implementation for style_dart.

style_mongo #

Style mongo is a DataAccess implementation for style_dart.

Usage #

Put To Component Tree #

@override
Component build(BuildContext context) {
  return Server(
      dataAccess: DataAccess(
          MongoDbDataAccessImplementation("<connection-string>")
      ),
      children: [
        //...
      ]);
}

OR


@override
Component build(BuildContext context) {
  return ServiceWrapper<DataAccess>(
    service: DataAccess(
        MongoDbDataAccessImplementation("<connection-string>")
    ),
    child: YourChildComponent(),
  );
}


Operate #

FutureOr<Object> onCall(Request request) {
  return Access(
    collection: "<collection>",
    type: type,

    // optional. necessary for some operations
    // you can also use "Query" 
    query: MongoQuery(where.eq("field", "value")),
    
    // optional. necessary for aggregation
    pipeline: AggregationPipelineBuilder(/*stages*/),
    // or pipeline: [{"\$project" : {"_id":0}}]
  );
}

You can operate with any different styles like DataAccess.of(ctx).read(..) .

Using with Query, selector parameter must be mongo db style Map. So must be where.eq("field", "value").map["\$query"].

Settings #

MongoDb have many operation settings like WriteConcern. You can set this settings with:

f(){
  final access = Access(
      settings: MongoDbFindSettings(findOptions: FindOptions(returnKey: true))
    //...
  );
}

There is settings for all operations, except count and exists

Example Usage with AccessPoint #

Check Example

1
likes
130
pub points
0%
popularity

Publisher

verified publisherstyledart.dev

MongoDb DataAccess implementation for style_dart.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

mongo_dart, style_dart

More

Packages that depend on style_mongo