
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
mongoose-rest-utils
Advanced tools
$ npm install -g mongoose-rest-utils
Utils allow you to perform basic and more or less complexe GET POST PUT and DELETE operations with mongoose !
The 4 methods (get, post, put and delete) take 4 arguments :
###GET
####PAGINATION The GET method can take severals parameters from the query object of the request for pagination:
req.query['limit'] = 5; //integer maximum number of result returned, same as SQL's limit
req.query['page'] = 5 //integer page you want to access, starting from 0, each page contains 'limit' result
####COUTING If you want to get a SQL COUNT equivalent, just provide this into the query :
req.query['count'] = true;
####FILTERING
It also takes severals parameter for filtering and/or populating field on the entity you request. For example let's say I want to get people whose firstname are John, exclude their age from the result, oh and ones with "Smith" lastname are ignored:
req.query["firstname"] = "John"; //firstname being the attribut in your model
req.query["no_age"] = true;
req.query["not_lastname"] = "Smith"; //case incensitive
####POPULATING
For now, utils provides populating up to 2 nesting.
Let's say I want to populate a car attribute of my entity :
req.query["populate_car"] = true;
Now I want to populate the car's model attribute at the same time :
req.query["populate_nested_car"] = "model";
Because nesting never stop, I want to populate the model's brand attribute :
req.query["populate_nested_deep_car_model"] = "brand";
However I'm sure there is a recursive way to deal with nested populate, not went into it so far.
###POST
The POST just create an entity passed into a "data" attribute from body.
req.body.data = {firstname : "John", lastname :"Doe"};
###PUT
The PUT just update an entity passed into a "data" attribute from body.
req.body.data = {_id : "e654fefeacde654", firstname : "John", lastname :"Doe"};
###DELETE
The DELETE just delete an entity with the id given in the url params attribute
Model.findOneAndRemove({_id: req.params.id}, function (err) {
if (err)
return res.status(500).json({success: false, data: err});
return res.status(200).json({success: true});
});
FAQs
Mongoose utils functions for REST API
We found that mongoose-rest-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.