- The purpose of this project is to support define REST Api Query quickly by mapping url params with mongodb query
- Compatible with koa (generator)
Examples:
- Querying article with commentsCount between 5 and 10
- Given:
minCommentsCount=5&maxCommentsCount=10
- And you have the config file like file: tests/process-filter.test.js & tests/article.model.js
- It will parse the filter into
{commentsCount: {$gte: 5,$lte: 10}
Usage:
BaseRepository
;const repository = Article ArticleSchemaconfig;const Article = mongoose;
View more at '/tests/base-repository.tests.js'
createController
;const controller = ;
Controller Function:
- query
- insert
- update
- getByKey
- getById
- getByFilter
- deleteById
- addChild
- removeChild
TODO
- Add Code Coverage
Run Test
npm install
npm test
Run Examples
npm install
Generate Data
node examples/generate-data
Run Example
node examples
Steps for generate Test Data
- Need a list of entities (real data).
- Transfer a list of entities into mongodb data & use as initial testing data