开发者

Erlang / Erlmongo : Mongo arrays

I can't find how to format my datas in Erlang and choose the encoding style provided by Erlmongo (default or mochijson) to be able to save datas as an Array in a Mongo document.

Example of a Mongo Document containing an array :

{
"_id" : MyId,
datas : [0,1,2,3]
}

This type of document is correct in Mongo开发者_如何学运维 format. But how to create such a document with the erlmongo driver ?


I believe that you want to build an erlang property list. Your example JSON document in mongo might look like this as an erlang proplist:

[
    {id, MyId},
    {datas, [0, 1, 2, 3]}
]

Try this out and let me know if it works. There are a couple different mongo drivers for erlang, and I think I've only used emongo.

Also, some advice that you didn't ask for: "data" is already the plural form of "datum". You don't add an "s".

Hope this helps.
-tjw

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜