Narwhal MongoDB的JavaScript驱动开源项目

我要开发同款
匿名用户2012年08月29日
62阅读

技术信息

开源地址
https://github.com/sergi/narwhal-mongodb
授权协议
未知

作品详情

Narwhal为CommoJS提供了访问MogoDB数据库的封装器。

示例代码:

varMogoDB=require("mogodb");vardb=ewMogoDB.Mogo().getDB("mydb");varcolls=db.getCollectioNames();colls.forEach(fuctio(el){prit(el);});varcoll=db.getCollectio("testCollectio");coll.drop();vardoc={"ame":"MogoDB","type":"database","cout":1,"ifo":{x:203,y:102}}coll.isert(doc)myDoc=coll.fidOe();prit(myDoc);//Now,letsaddlotsoflittledocumetstothecollectiosowecaexplorequeriesadcursorsfor(vari=0;i<100;i++){coll.isert({"i":i});}prit(coll.getCout());//Let'sgetallthedocumetsithecollectioadpritthemoutvarcur=coll.fid();while(cur.hasNext()){prit(cur.ext());}//Nowuseaquerytoget1documetoutvarquery={i:71};cur=coll.fid(query);while(cur.hasNext())prit(cur.ext());//Nowuseaquerytogetalargersetquery={"i":{"$gt":50}};//i.e.fidallwherei>50cur=coll.fid(query);while(cur.hasNext())prit(cur.ext());

 

功能介绍

Narwhal 为 CommonJS 提供了访问 MongoDB 数据库的封装器。 示例代码:
var MongoDB = require("mongodb");
var db = new...

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论