简体   繁体   English

如何使用mongodb-erlang驱动程序在Erlang中删除mongo集合?

[英]How can I drop a mongo collection in Erlang with the mongodb-erlang driver?

How can I drop a MongoDB collection in Erlang using the mongodb-erlang driver ( https://github.com/mongodb/mongodb-erlang )? 如何使用mongodb-erlang驱动程序( https://github.com/mongodb/mongodb-erlang )在Erlang中删除MongoDB集合?

I didn't find anything in the docs: http://api.mongodb.org/erlang/mongodb/ 我在文档中找不到任何内容: http : //api.mongodb.org/erlang/mongodb/

I'm writing tests that create collections with different names and I want to drop them when the tests are finished. 我正在编写使用不同名称创建集合的测试,我想在测试完成后将其删除。 I can delete all the documents in a collection, but I want to drop the collection itself. 我可以删除集合中的所有文档,但是我想删除集合本身。

Use the mongo_query:command/3 function and the document form of the drop command: 使用mongo_query:command / 3函数和drop命令的文档形式:

1> mongo_query:command({Db, Conn}, {drop, 'foo.bar.baz'}, false).
{nIndexesWas,1.0,msg,<<"indexes dropped for collection">>,
ns,<<"foo.bar.baz">>,
ok,1.0}

Takes a regular connection, not a replset connection. 建立常规连接,而不是replset连接。

mongo_query:command/3 function: mongo_query:command / 3函数:
http://api.mongodb.org/erlang/mongodb/mongo_query.html#command-3 http://api.mongodb.org/erlang/mongodb/mongo_query.html#command-3

Document form of MongoDB drop command function: MongoDB drop命令功能的文件格式:
http://docs.mongodb.org/manual/reference/command/drop/#dbcmd.drop http://docs.mongodb.org/manual/reference/command/drop/#dbcmd.drop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM