Git Product home page Git Product logo

mongoose-router's Introduction

mongoose-express-router

Create Express 4 router and middleware from Mongoose 4 model.

Usage

var express = require('express');
var mongoose = require('mongoose');
var router = require('mongoose-express-router');

var db = mongoose.createConnection('mongodb://localhost/test');
var schema = mongoose.Schema({ name: 'string' });
var User = mongoose.model('User', schema);

var app = express();
app.use('/users', router(User));

app.listen(3000);

The underlying mongoose-controller used by each middleware is available, as well as the middleware functions themselves:

router(User).middleware
router(User).controller

Queries

The following query parameters are recognized:

  • skip or offset
  • limit
  • sort
  • select
  • populate
  • where *

*: where depends on the availability of nested query string parameters.

In addition, any req.params will be assigned as where parameters. This is useful if nested query parameters are not available, as multiple routes can point to one instance of a router. For example:

var app = express();
var r = router(Model);

app.use('/model/skip/:skip', r);
app.use('/model', r);

Body parsing

You must provide your own body parsing middleware. A req.body object must be available for the post/create middleware to work.

Builtin middleware

Incomplete

mongoose-router's People

Contributors

alexmingoia avatar sammoore avatar

Watchers

 avatar  avatar  avatar

Forkers

ankush86

mongoose-router's Issues

Update README

Issues found so far:

  • package name used in require statements uses the old package's name, not the current one

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.