0.7.0 • Published 9 years ago

base-repository v0.7.0

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

Build Status

Coverage Status

  • 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

import * as ArticleSchema from './article.model';
const repository = new BaseRepository(Article, ArticleSchema.config);
const Article = mongoose.model(ArticleSchema.schemaName, ArticleSchema.schema);

View more at '/tests/base-repository.tests.js'

createController

import { createController } from 'base-repository';
const controller = createController(repository);

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
0.7.0

9 years ago

0.6.5

9 years ago

0.6.4

9 years ago

0.6.3

9 years ago

0.6.2

9 years ago

0.6.1

9 years ago

0.6.0

9 years ago

0.5.4

9 years ago

0.5.3

9 years ago

0.5.2

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.2

9 years ago

0.4.0

9 years ago

0.3.8

9 years ago

0.3.7

10 years ago

0.3.6

10 years ago

0.3.5

10 years ago

0.3.4

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago