首页 > 代码库 > Mango DB

Mango DB

mango db/no sql

benefits

1. no requirement for script for creating tables. column and constraints

2. good for rich model expeciaaly aggregate root to manage its subentities.e.g. the order total amount can be coded by the aggregaye object rather than the mvc controller.

3 GridFs to support query

4 easy to scale out

5 flexible schema

 

driver for .net

choose mangodbforcsharp nuget

mangoclient and mangoserver are 2 types that inter play with each other.

 

create collection in server object can create mango db with this simple method.

 

create db instance - download db from website, create folder Db, run the mangod command

 

add mango driver to mvc project

 

bson is the document model /representation for json. it provides better machanism for client to traverse document while json along cannot achieve. c# poco  can be serialize into bson document, it is the same with json but only bson document can be  query

 

robomongo is a great visual tool to manage mangi db.

 

modification can be Replace or Update. Replace is an upsert api .

 

concurrency need to be cosidered. version check is one of the approach , adds that in the condition of the update to avoid dirty write.

 

Delete

 

Query

Find mango db support query (eq, ne, gte keyworks)objects which help to return cursor, poco, casted objects. and work well with linQ.

 

mangocursor - return a cursor that takez class name and return for client.

LinQ  - apply the AsQueryable() method to the document collection object and return a ienumerable and then perdorm linq query.

 

Sort

Aggregate method on bsoncollection object Again use the filter object array (new beason document and nested bson)  to perform the group, subtract and sort. define fields for the output json.

 

pagination

 

Performance

index is offered in mango!!

use match file to reduce impact docs

limit return fields

 

GridFs is technique that mango db stoing binary files.

Mango DB