Mingo MongoDB 查询的 JavaScript 实现

程序名称:Mingo

授权协议: MIT

操作系统: 跨平台

开发语言: JavaScript

Mingo 介绍

Mingo 是 MongoDB 查询语言的 JavaScript 实现。

Mingo 利用 MongoDB 风格查询,在客户端或者服务器端环境下,允许直接查询内存的 JavaScript 对象。

特性:

  • Comparisons Operators ($gt, $gte, $lt, $lte, $ne, $nin, $in)

  • Logical Operators ($and, $or, $nor, $not)

  • Evaluation Operators ($regex, $mod, $where)

  • Array Operators ($all, $elemmatch, $size)

  • Element Operators ($exists, $type)

  • Aggregation Pipeline Operators ($group, $match, $project, $sort, $limit, $unwind, $skip)

  • Conditional Operators ($cond, $ifNull)

  • Group Operators ($addToSet, $sum, $max, $min, $avg, $push, $first, $last)

  • Arithmetic Operators ($add, $divide, $mod, $multiply, $subtract)

  • String Operators ($cmp, $strcasecmp, $concat, $substr, $toLower, $toupper)

  • Set Operators ($setEquals, $setIntersection, $setDifference, $setUnion, $setIsSubset, $anyElementTrue, $allElementsTrue)

  • Projection Operators ($elemmatch, $slice)

  • JSON stream filtering and projection. NodeJS only

使用

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 }
});

搜索和过滤

// 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);

Mingo 官网

https://github.com/kofrasa/mingo

相关编程语言

MuPlayer 是一款跨平台、轻量级的音频播放解决方案,...
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个...
DewPlayer音乐播放器,样式很简单,而且很实用.播放器...
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Fla...
Speakker 是一个基于 Web 浏览器的音乐播放器,只提...
Player Framework 是一个开源的支持 HTML5 的视频播...