
Research
/Security News
60 Malicious Ruby Gems Used in Targeted Credential Theft Campaign
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
mongoose-datatables
Advanced tools
Server side table request.
$ npm install mongoose-datatables
Configure the plugin in your model
var mongoose = require('mongoose')
var dataTables = require('mongoose-datatables')
var Schema = mongoose.Schema
var UserSchema = new Schema({
first_name: String,
last_name: String,
username: String
})
UserSchema.plugin(dataTables)
Use plugin in your route
app.post('/table', (req, res) {
User.dataTables({
limit: req.body.length,
skip: req.body.start,
search: {
value: req.body.search.value,
fields: ['username']
},
sort: {
username: 1
}
}).then(function (table) {
res.json(table); // table.total, table.data
})
});
options.totalKey
(String) - Default totaloptions.dataKey
(String) - Default dataoptions.formatters
(Object) - Specifies multiple formatters that can be used in the queryoptions.limit
(Number) - Specifies mongo limit.options.skip
(Number) - Specifies mongo skip.options.find
(Object) - Specifies selection criteria.options.select
(Object) - Specifies the fields to return.options.sort
(Object) - Specifies the order in which the query returns matching documents.options.order
, options.columns
(Array), (Array) - Specifies the order in which the query returns matching documents and replace the sort optionoptions.search
(Object) - Search.options.populate
(Object) - Specifies models to populate.options.formatter
(String|Function) - Specifies formatter to use after the query.At query level
User.dataTables({
limit: 20,
formatter: function(user) {
return {
name: user.first_name + ' ' + user.last_name
}
}
})
At schema level
UserSchema.plugin(dataTables, {
formatters: {
toPublic : function (user) {
return {
name: user.first_name + ' ' + user.last_name
}
}
}
});
Use by doing this at query level
User.dataTables({
limit: 20,
formatter: 'toPublic',
})
Note: if you use formatters you get an array of objects on data, instead of the model instance.
MIT
FAQs
Server side dataTable request
The npm package mongoose-datatables receives a total of 284 weekly downloads. As such, mongoose-datatables popularity was classified as not popular.
We found that mongoose-datatables 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.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.