MongoDB 通过连字符的集合的名称
我使用该计划 Node.js 将数据插入数据库中 MongoDB. 我将数据插入收集名称 "repl-failOver".
当我使用时 Mongo shell 并列出数据库中的集合
, 我可以看到集合 "repl-failOver".
如何运行命令 find 的 mongo shell 这个系列?
var mongoClient = require/"mongodb"/.MongoClient;
mongoClient.connect/"mongodb://localhost:30002/test", function/err, db/ {
if /err/ throw err;
db.collection/"repl-failOver"/.insert/ { "documentNumber" : document++}, function /err, doc/ {
if /err/ throw err;
console.log/doc/;
}/;
db.close//;
}/;
当我使用时 Mongo shell 并列出数据库中的集合
show collections
, 我可以看到集合 "repl-failOver".
如何运行命令 find 的 mongo shell 这个系列?
没有找到相关结果
已邀请:
2 个回复
帅驴
赞同来自:
db['repl-failOver'].find/{}/
或者
您可以在该节中找到更多详细信息
http://docs.mongodb.org/manual ... eries
手册:
如果一个 mongo shell 不接受集合的名称,
例如,如果名称包含空格,则为连字符或从
数字,您可以使用替代语法进行集合的链接
显示下面:
帅驴
赞同来自:
,
,
/. 我解释说明
旁路路径,但大多数是你所需要的只是做