koa-rest-mongoose
mongoose rest generator for koa1
Installation
npm install koa-rest-mongoose
Usage
const koa = ;const mongoose = ;const KoaRestMongoose = ; // 1 step, mongooseconst mongoUrl = '127.0.0.1:27017/koa_rest_mongoose';const schema = email: String name: String password: String address: String zipcode: Number lists: Array; mongoose;mongoose; // 2 step, koa and routerconst app = ;const rest = ;app; // 3 step, doneapp;
TODO feature
- middlewares support
API
Following REST API is now created for you:
HTTP Verb | /users | /users/:id |
---|---|---|
GET | Get all documents, or documents that match the query. You can use mongoose find conditions, limit, skip and sort. For example: /api/users?conditions={"name":"john"}&limit=10&skip=1&sort=-zipcode |
Get the addressed document. |
POST | Create a new document and send it back. | Update the addressed document with specified attributes. |
PUT | Create a new document and send it back. | Replace the addressed document. |
DELETE | n/a | Delete the addressed document. |
PATCH | n/a | Update the addressed document with specified attributes. |