![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
JavaScript implementation of MongoDB query language
Mingo harnesses the power of MongoDB-style queries and allows direct querying of in-memory javascript objects in both client and server-side environments. This library is self-contained and has zero-dependencies
$ npm install mingo
In browser
<script type="text/javascript" src="./dist/mingo.min.js"></script>
For documentation on using query operators see mongodb
var Mingo = require('mingo');
// or just access *Mingo* global in browser
// 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
var query = new Mingo.Query({
type: "homework",
score: { $gte: 50 }
});
// `collection` is an Array of objects you want to query
// filter collection with find()
var 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
cursor.count();
// iterate cursor
// iteration is forward only
while (cursor.hasNext()) {
console.log(cursor.next());
}
// use first(), last() and all() to retrieve matched objects
cursor.first();
cursor.last();
cursor.all();
// Filter non-matched objects (
var result = query.remove(collection);
var agg = new Mingo.Aggregator([
{'$match': { "type": "homework"}},
{'$group':{'_id':'$student_id', 'score':{$min:'$score'}}},
{'$sort':{'_id': 1, 'score': 1}}
]);
var result = agg.run(collection);
// shorthand
result = Mingo.aggregate(
collection,
[
{'$match': { "type": "homework"}},
{'$group':{'_id':'$student_id', 'score':{$min:'$score'}}},
{'$sort':{'_id': 1, 'score': 1}}
]
);
// using Backbone.Collection as an example (any user-defined object will do)
var Grades = Backbone.Collection.extend(Mingo.CollectionMixin);
// `collection` is an array of objects
var 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.first();
The collection to mixin needs to provide a method with signature toJSON() -> Array[Object]
.
MIT
v1.2.0 / 2017-07-17
$where
operator not executed last. https://github.com/kofrasa/mingo/pull/50$facet
and $bucket
operators$bucketAuto
operator without granularity support$type
operatorMingo.OP_<name>
FAQs
MongoDB query language for in-memory objects
The npm package mingo receives a total of 59,989 weekly downloads. As such, mingo popularity was classified as popular.
We found that mingo demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.