Skip to content

Style framework Mongodb database implementation

License

Notifications You must be signed in to change notification settings

Mehmetyaz/style_mongo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Style framework Mongodb database implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Dart 100.0%