New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mortimer

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mortimer - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

13

CHANGELOG.md

@@ -1,3 +0,14 @@

### Changelog
# Changelog
## Version 1.1.0 - Jan 19, 2015
* Implement `PUT /<resource>/:<resource>Id` to completely replace document.
* Implement `PATCH /<resource>` to update a set of selected documents.
* Implement `DELETE /<resource>` to remove a set of selected documents.
* Improve documentation accross the board.
* Update examples and README.md to showcase the new endpoints.
## Version 1.0.1 - Jan 17, 2015
* Patch error capturing and reporting by the api.
* Improve methods documentation
## Version 1.0.0 - Jan 13, 2015

@@ -4,0 +15,0 @@ * Bump major version! This version is no longer compatible with previous ones!

@@ -57,2 +57,13 @@ // Generated by CoffeeScript 1.8.0

Resource.prototype.putDoc = function(options) {
if (options == null) {
options = {};
}
return [
this.namespace(), this.read(), this.execute(), this.put(), this.publish({
statusCode: 200
})
];
};
Resource.prototype.removeDoc = function(options) {

@@ -81,2 +92,25 @@ if (options == null) {

Resource.prototype.patchDocs = function(options) {
if (options == null) {
options = {};
}
return [
this.namespace(), this.readAll(), this.pagination(), this.filters(), this.sort(), this.patchAll(), this.publish({
statusCode: 200
})
];
};
Resource.prototype.removeDocs = function(options) {
if (options == null) {
options = {};
}
return [
this.namespace(), this.readAll(), this.pagination(), this.filters(), this.sort(), this.removeAll(), this.publish({
statusCode: 200,
empty: true
})
];
};
Resource.prototype.countDocs = function(options) {

@@ -92,3 +126,3 @@ if (options == null) {

return [
this.namespace(), this.readAll(), this.filters(), this.count(), this.publish({
this.namespace(), this.readAll(), this.filters(), this.countAll(), this.publish({
statusCode: 200

@@ -172,2 +206,31 @@ })

Resource.prototype.put = function(options) {
if (options == null) {
options = {};
}
return (function(_this) {
return function(req, res, next) {
return req[_this.ns].result.remove(function(error) {
var document;
if (error != null) {
return res.status(500).send({
msg: "Failed to replace the document"
});
}
document = new _this.Model(req.body);
document._id = req[_this.ns].result._id;
return document.save(function(error) {
if (error != null) {
return res.status(500).send({
msg: "Error replacing document"
});
}
req[_this.ns].result = document;
return next();
});
});
};
})(this);
};
Resource.prototype.remove = function(options) {

@@ -203,3 +266,3 @@ if (options == null) {

Resource.prototype.count = function(options) {
Resource.prototype.patchAll = function(options) {
if (options == null) {

@@ -210,2 +273,47 @@ options = {};

return function(req, res, next) {
req[_this.ns].query.setOptions({
multi: true
});
return req[_this.ns].query.update(req.body, function(error) {
if (error != null) {
return res.status(500).send({
msg: 'Unable to patch selected documents'
});
}
return next();
});
};
})(this);
};
Resource.prototype.removeAll = function(options) {
if (options == null) {
options = {};
}
return (function(_this) {
return function(req, res, next) {
return req[_this.ns].query.remove(function(error, numDocsRemoved) {
if (error != null) {
return res.status(500).send({
msg: 'Failed to remove selected documents'
});
}
return next();
});
};
})(this);
};
Resource.prototype.updateAll = function(options) {
if (options == null) {
options = {};
}
};
Resource.prototype.countAll = function(options) {
if (options == null) {
options = {};
}
return (function(_this) {
return function(req, res, next) {
return req[_this.ns].query.count(function(error, count) {

@@ -212,0 +320,0 @@ if (error != null) {

2

package.json
{
"name": "mortimer",
"version": "1.0.1",
"version": "1.1.0",
"description": "rest interface for mongoose models, built on top of express",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/topliceanu/mortimer",

@@ -66,4 +66,8 @@ # mortimer = MOngoose ResT

app.get('/books', resource.readDocs());
app.get('/books/count', resource.countDocs());
app.patch('/books', resource.patchDocs());
app.delete('/books', resource.removeDocs());
app.get('/books/:bookId', resource.readDoc());
app.patch('/books/:bookId', resource.patchDoc());
app.put('/books/:bookId', resource.putDoc());
app.delete('/books/:bookId', resource.removeDoc());

@@ -70,0 +74,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc