
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
@jsreport/mingo
Advanced tools
JavaScript implementation of MongoDB query language
$ npm install mingo
<array>.<index>
and <document>.<field>
selectorsFor documentation on using query operators see mongodb
On the server side
// Use as es6 module
import mingo from 'mingo'
// or vanilla nodeJS
var mingo = require('mingo')
For the browser
// minified UMD module
<script type="text/javascript" src="./dist/mingo.min.js"></script>
// or gzipped UMD module
<script type="text/javascript" src="./dist/mingo.min.js.gz"></script>
Tiny configuration if needed
// setup the key field for your collection
mingo.setup({
key: '_id' // default
});
// create a query with criteria
// find all grades for homework with score >= 50
let query = new mingo.Query({
type: "homework",
score: { $gte: 50 }
});
// test if an object matches query
query.test(someObject)
// input is either an Array or any iterable source (i.e Object{next:Function}) including ES6 generators.
// filter collection with find()
let cursor = query.find(collection)
// shorthand with query criteria
cursor = mingo.find(collection, criteria)
// sort, skip and limit by chaining
cursor.sort({student_id: 1, score: -1})
.skip(100)
.limit(100)
// count matches. exhausts cursor
cursor.count()
// classic cursor iterator (old school)
while (cursor.hasNext()) {
console.log(cursor.next())
}
// ES6 iterators (new cool)
for (let value of cursor) {
console.log(value)
}
// all() to retrieve matched objects. exhausts cursor
cursor.all()
let agg = new mingo.Aggregator([
{'$match': { "type": "homework"}},
{'$group':{'_id':'$student_id', 'score':{$min:'$score'}}},
{'$sort':{'_id': 1, 'score': 1}}
])
// return an iterator for streaming results
let stream = agg.stream(collection)
// return all results. same as `stream.all()`
let result = agg.run(collection)
// using Backbone.Collection as an example (any user-defined object will do)
let Grades = Backbone.Collection.extend(mingo.CollectionMixin)
// `collection` is an array of objects
let grades = new Grades(collection)
// find students with grades less than 50 in homework or quiz
// sort by score ascending and type descending
cursor = grades.query({
$or: [{type: "quiz", score: {$lt: 50}}, {type: "homework", score: {$lt: 50}}]
}).sort({score: 1, type: -1}).limit(10)
// return grade with the lowest score
cursor.next()
The collection to mixin needs to provide a method with signature toJSON() -> Array[Object]
.
make
to ensure tests passMIT
FAQs
JavaScript implementation of MongoDB query language
The npm package @jsreport/mingo receives a total of 3,964 weekly downloads. As such, @jsreport/mingo popularity was classified as popular.
We found that @jsreport/mingo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.