mongoose-adapter
Make the mongoose easy to use.
Install
Install the components
$ npm install mongoose-adapter mockgoose mongoose --save
Quick Start
You can use TypeScirpt or JavaScript. Up to you.
TypeScript
Implement the BaseRepository for your mongoose collections.
//myUnitOfWork.ts;; { super; } reps = personRep: this ; //personRep.ts;; <IPerson> { superunitOfWork; } { return 'Person'; } : mongooseSchema const userSchema = _id: type: String index: unique: true name: type: String age: type: Number birthday: type: Date ; const s = userSchema; return s;
Examples for CRUD
// ==== create data =====let myDb = ; var entity = myDbrepspersonRep;entity_id = "1qaz2wsx";entityname = "Bibby Chung";entityage = 18;entitybirthday = "1990-04-01 13:20:30";myDb; await myDb; //==== update data ====let myDb = ; let data = await myDbrepspersonRep ; let entity = data0;entityname = "Bibby Chung 1";entityage = 22;entitybirthday = "1995-08-08 13:20:30";myDb; await myDb; //==== delete data ====let myDb = ; let data = await myDbrepspersonRep ; for let item of data myDb; await myDb; //==== get data ====let myDb = ; let data = await myDbrepspersonRep ;
JavaScript
(later..)
Todo
- add the transacation