包详细信息

mongoose-rest-actions

lykmapipo331MIT0.30.6

mongoose rest actions on top of express

lykmapipo, mongoose, mongoose-plugin, express

自述文件

mongoose-rest-actions

Build Status Dependency Status npm version

mongoose rest actions on top of expressjs

Note: You may install express-mquery to have http query parameter parsed to valid mongoose query criteria

Installation

$ npm install --save mongoose mongoose-rest-actions express-mquery

Usage

const express = require('express');
const mquery = require('express-mquery');
const mongoose = require('mongoose');
const actions = require('mongoose-rest-actions');
mongoose.plugin(actions);

//... register & load mongoose models

mongoose.connect('<url>');


const app = express();
app.use(mquery({limit: 10, maxLimit: 50}));
const User = mongoose.model('User');

app.get('/users', function(request, response, next) {

  const options = request.mquery;

  User
    .get(options, function(error, results) {
      ...handle error or reply
    });

});


app.post('/users', function(request, response, next) {

  const body = request.body;

  User
    .post(body, function(error, user) {
      ...handle error or reply
    });

});


app.get('/users/:id', function(request, response, next) {

  const _id = request.params.id;

  User
    .getById(_id, function(error, user) {
      ...handle error or reply
    });

});


app.put('/users/:id', function(request, response, next) {

  let updates = request.body;
  const _id = request.params.id;

  User
    .put(_id, updates, function(error, user) {
      ...handle error or reply
    });

});


app.patch('/users/:id', function(request, response, next) {

  let updates = request.body;
  const _id = request.params.id;

  User
    .patch(_id, updates, function(error, user) {
      ...handle error or reply
    });

});


app.delete('/users/:id', function(request, response, next) {

  const _id = request.params.id;

  User
    .del(_id, function(error, user) {
      ...handle error or reply
    });

});

...

Testing

  • Clone this repository

  • Install all development dependencies

$ npm install
  • Then run test
$ npm test

Contribute

It will be nice, if you open an issue first so that we can know what is going on, then, fork this repo and push in your ideas. Do not forget to add a bit of test(s) of what value you adding.

Licence

The MIT License (MIT)

Copyright (c) 2018 - present lykmapipo & Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

更新日志

0.30.6 (2020-08-08)

Chores
  • deps: force latest version & audit fix (12464163)

0.30.5 (2020-07-29)

Chores
  • deps: force latest version & audit fix (dfef07cf)

0.30.4 (2020-07-14)

Chores
  • deps: force latest version & audit fix (376ddd99)

0.30.3 (2020-07-02)

Chores
  • deps: force latest version & audit fix (af243d48)

0.30.2 (2020-06-26)

Chores
  • deps: force latest version & audit fix (77b072af)

0.30.1 (2020-06-10)

Chores
  • deps: force latest version & audit fix (9f9340d4)

0.30.0 (2020-05-31)

Refactors
  • merge updates on put & patch (cac53d3d)

0.29.24 (2020-05-20)

Chores
  • deps: force latest version & audit fix (108ac4ce)

0.29.23 (2020-05-09)

Chores
  • deps: force latest version & audit fix (5003235c)

0.29.22 (2020-05-02)

Chores
  • deps: force latest version & audit fix (04f88f9e)

0.29.21 (2020-04-27)

Chores
  • deps: force latest version & audit fix (bf12afc8)

0.29.20 (2020-04-16)

Chores
  • deps: force latest version & audit fix (dbe64ce1)

0.29.19 (2020-03-30)

Chores
  • deps: force latest version & audit fix (ad638082)

0.29.18 (2020-03-06)

Chores
  • deps: force latest version & audit fix (9b86bd57)

0.29.17 (2020-02-28)

Chores
  • deps: force latest version & audit fix (0ac1b21b)

0.29.16 (2020-02-16)

Chores
  • deps: force latest version & audit fix (55d9a922)

0.29.15 (2020-02-04)

Chores
  • deps: force latest version & audit fix (585629d5)

0.29.14 (2020-01-24)

0.29.13 (2020-01-22)

Chores
  • deps: force latest version & audit fix (f91808f4)

0.29.12 (2020-01-17)

Chores
  • deps: force latest version & audit fix (976f1ae2)

0.29.11 (2020-01-14)

Chores
  • deps: force latest version & audit fix (6468ddcd)

0.29.10 (2020-01-12)

Chores
  • deps: force latest version & audit fix (ce3e8ed6)

0.29.9 (2019-12-17)

Chores
  • deps: force latest version & audit fix (c4b87bb6)

0.29.8 (2019-12-13)

Chores
  • deps: force latest version & audit fix (56c127f4)

0.29.7 (2019-11-26)

Chores
  • deps: force latest version & audit fix (993420e5)

0.29.6 (2019-11-14)

Chores
  • deps: force latest version & audit fix (51e89057)

0.29.5 (2019-10-23)

Chores
  • deps: force latest version & audit fix (71a86ae7)

0.29.4 (2019-10-10)

Chores
  • deps: force latest version & audit fix (408994d3)

0.29.3 (2019-10-03)

Chores
  • deps: force latest version & audit fix (6afafbdd)

0.29.2 (2019-10-02)

Chores
  • deps: force latest version & audit fix (aa9445d1)

0.29.1 (2019-09-28)

Chores
  • deps: force latest version & audit fix (a8c0b064)

0.29.0 (2019-09-27)

Chores
  • deps: force latest version & audit fix (c6d67850)
New Features
  • merge existing paths with updates (e6e05757)

0.28.11 (2019-09-27)

Chores
  • deps: force latest version & audit fix (9be7b7fe)

0.28.10 (2019-09-26)

Chores
  • deps: force latest version & audit fix (626aee77)

0.28.9 (2019-09-16)

Chores
  • deps: force latest version & audit fix (203410b1)

0.28.8 (2019-08-20)

Chores
  • deps: force latest version & audit fix (f7cf9a60)

0.28.7 (2019-08-14)

Chores
  • deps: force latest version & audit fix (58ab7cd2)

0.28.6 (2019-07-09)

Chores
  • deps: force latest version & audit fix (b089a8cd)

0.28.5 (2019-06-19)

Chores
  • deps: force latest version & audit fix (2bdbf831)

0.28.4 (2019-06-10)

Chores
  • deps: force latest version & audit fix (c00d45c0)

0.28.3 (2019-06-09)

Chores
  • deps: force latest version & audit fix (b2fc3804)

0.28.2 (2019-06-04)

Chores
  • deps: force latest version & audit fix (65673cfe)

0.28.1 (2019-05-20)

Chores
  • deps: force latest version & audit fix (983f077d)

0.28.0 (2019-05-20)

Chores
  • deps: force latest versions & audit fix (14edc7d3)
New Features
  • put: add support to filter (da2d4728)
  • delete: add support to filter (d099ee1e)
  • get-by-id: add support to filter (f8ce3d36)
Bug Fixes
  • correct hasMore computation using pages > page (8f68ac02)
Tests
  • debug and test put with filter options (2b02beb9)
  • debug and test patch with filter options (a2eb7e6b)
  • debug and test delete with filter options (9ff300db)
  • debug and test getById with filter options (825d33c2)

0.27.2 (2019-05-12)

Chores
  • deps: force latest version & audit fix (65982a7a)

0.27.1 (2019-05-12)

Chores
  • deps: force latest version & audit fix (786394b2)

0.27.0 (2019-05-10)

Chores
  • deps:
    • force latest version & audit fix (4aa95fff)
    • force latest version & audit fix (f759d9b3)
New Features
  • get-by-id: add before and after getById static hooks (279850d7)
  • ignore _id & updatedAt updates on instance.put method (5a645383)
  • ignore instances on put static method (85b08458)
  • add hasMore flag or list responses (026d075f)
Other Changes
  • get: use orFail when getById (79616ac3)
Refactors
  • ensure error status & pre/post hooks executions (c83496cf)
  • patch: support instance & refs as updates (034b2f97)
  • put: honour instances as updates (cb7e5106)
  • static-put: use orFail when finf existing (6539b77d)
Code Style Changes
  • collapse jsdocs exceed 80 ruler (7df13972)
Tests
  • spy invocation of exec on put and patch (8ef6806f)
  • fix put instances using model static put (56cebb68)

0.26.0 (2019-05-05)

Chores
  • deps: force latest versions & audit fixes (7825170b)
New Features
  • allow static soft delete option (20952127)
  • allow instance soft delete option (22978ee0)
Refactors
  • plugin: reorder rest actions plugin on schema (d0844323)

0.25.4 (2019-05-01)

Chores
  • deps: force latest version & audit fix (f96a3587)

0.25.3 (2019-05-01)

Chores
  • ci: force latest nodejs (c4f357ed)
  • .npmrc: prevent npm version to commit and tag version (3a995d1b)
  • deps: force latest version & audit fix (eba69bae)

0.25.2 (2019-04-27)

Chores
  • dependencies:
  • release: generate latest changelog & bump to v0.25.1 (7c6b81c7)
  • fix dependency security vulnerability (c5370860)
Code Style Changes

0.25.1 (2019-04-24)

Chores

0.25.0 (2019-04-21)

Chores
Refactors
  • post: use instance save & improve specs (6ba006c5)
Tests
  • unit:
    • drop repetable specs (8cc6bea3)
    • refactor index specs to use test helpers (0797d855)
    • refactor get specs to use test helpers (5ce3e39d)
    • refactor post specs to use test helpers (0cbd321a)
    • refactor patch specs to use test helpers (88f4232f)
    • refactor to use test helpers (ff8e223b)
    • refactor delete to use test helpers (cc8adf7f)
    • refactor to use test helpers (e81f82b1)
  • refactor to use test helpers (a55a68cd)
  • improve delete test (7c836290)
  • refactor bootstrap to use test helpers (57badbb4)
  • integration:
    • refactor & improve get and fresh specs (c6bb9056)
    • refactor & improve getById specs (cc8cda76)
    • refactor & improve put specs (e9d91a93)
    • improve unique error beautify specs (a5749928)
    • refactor & improve patch spec (55cdac32)
    • ensure valid post assertions (1bfb8991)
    • refactor post specs (a8c58caf)
    • improve delete actions spec (de7460d2)
    • refactor delete spec to use test models (4b6d4775)

0.24.1 (2019-04-16)

Chores
Documentation Changes
  • add code of conduct and contributing guide (a709ead2)

0.24.0 (2019-03-29)

Chores
New Features
  • add mongoose-aggregatable plugin (8f5149bf)
Bug Fixes
  • resolve issue in unit tests related to sinon (f65a0761)
Refactors
  • remove console.log (1a2e1862)
  • ensure same formatting style across editors (763e523b)
Code Style Changes
  • fix a typo on code documentation (fe647d9a)

0.23.1 (2019-02-14)

Chores
  • force latest mongoose-faker (b1070bdf)

0.23.0 (2019-02-13)

New Features
  • allow short-circuit filtered search (4c0a0976)