mongodb-erlang Erlang司机示例 [英] mongodb-erlang Erlang driver examples

查看:161
本文介绍了mongodb-erlang Erlang司机示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里可以找到mongodb-erlang用法的例子?
我发现的唯一的信息来源是这个文件:
https://github.com/TonyGen/mongodb-erlang/blob/master/src/mongodb_tests.erl
但是它没有涵盖许多基本的查询,如下所示(从MongoDB网站中挑选):

  db.collection.find()。sort({name:1,age:-1})。limit 10); 
db.users.find()。skip(20).limit(10);
db.things.ensureIndex({j:1});
db.things.find({colors:{$ ne:red}});
db.collection.find({field:{$ gte:value}});
db.things.find({xa:1,xb:{$ gt:1}})

所以如何用erlang驱动程序编写这些查询?

解决方案

对于官方支持的驱动程序API记录在这里:



http:/ /api.mongodb.org/erlang/mongodb/



对于查找操作,请查看函数索引,具体来说:



http://api.mongodb.org/ erlang / mongodb / mongo.html#find-2



如果这不是你的口味,你可能还想查看社区驱动程序: / p>

emongo / erlmongo - 他们各自的自述文件和文档也有一些例子:



https://github.com/wpntv/erlmongo


Where i can find examples of mongodb-erlang usage ? The only source of information i found is this file: https://github.com/TonyGen/mongodb-erlang/blob/master/src/mongodb_tests.erl But it not covers many of basic queries like following (picked from MongoDB site):

db.collection.find().sort({name : 1, age: -1}).limit(10);
db.users.find().skip(20).limit(10);
db.things.ensureIndex({j:1});
db.things.find({colors : {$ne : "red"}});
db.collection.find({ "field" : { $gte: value } } );
db.things.find( { "x.a" : 1, "x.b" : { $gt : 1 } } )

So how to write these queries in terms of erlang driver ?

解决方案

For the officially supported driver the API is documented here:

http://api.mongodb.org/erlang/mongodb/

For the find operations check out the function index, specifically:

http://api.mongodb.org/erlang/mongodb/mongo.html#find-2

If that is not to your taste, you may want to also check out the community drivers:

emongo/erlmongo - their respective READMEs and docs have some examples too:

https://bitbucket.org/rumataestor/emongo

https://github.com/wpntv/erlmongo

这篇关于mongodb-erlang Erlang司机示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆