我有一个json文件如下:
{
"_id" : ObjectId("553547d3864c23ae8837f8f2"),
"labels" : {
"id" : "1",
"name" : "Planet E",
"sublabels" : "Antidote (4)Community ProjectsGuilty PleasuresI Ner Zon SoundsPlanet E Communications, Inc.TWPENTY",
"contactinfo" : "Planet E Communications\nP.O. Box 27218\nDetroit, 48227, USA\n\np: 313.874.8729 \nf: 313.874.8732\n\nemail: info AT Planet-e DOT net\n",
"profile" : "Classic Techno label from Detroit, USA.\n[b]Label owner:[/b] [a=Carl Craig].\n",
"dataquality" : "Needs Vote",
"urls" : "http://planet-e.nethttp://planetecommunications.bandcamp.comhttp://www.discogs.com/user/planetedetroithttp://www.facebook.com/planetedetroithttp://www.flickr.com/photos/planetedetroithttp://plus.google.com/100841702106447505236http://myspace.com/planetecomhttp://myspace.com/planetedetroithttp://soundcloud.com/planetedetroithttp://twitter.com/planetedetroithttp://vimeo.com/user1265384http://www.youtube.com/user/planetedetroithttp://en.wikipedia.org/wiki/Planet_E_Communications"
}
}
Run Code Online (Sandbox Code Playgroud)
当我使用以下命令
db.labels.find({name: "Planet E"})
Run Code Online (Sandbox Code Playgroud)
我得到以下结果
我究竟做错了什么?
我update
在mongodb
数据库上运行一个语句,它删除了我的文档!我做错了什么?
这是更新声明:
db.Question.update( {Name: "IsSomeCompany"}, {ButtonValues: [0, 1, 2] } )
Run Code Online (Sandbox Code Playgroud)
我正在使用Robomongo
和回复,Updated 1 record(s) in 22ms
但当我检查数据库时,记录消失了.我在这里错过了什么?
我正在尝试在Mac下使用Robomongo(或Robo 3T)来控制远程Ubuntu和Nginx服务器中的mongodb.
通常,我需要ssh xxx.xx.xx.xx
在终端中使用用户名和密码连接到服务器.在/etc/nginx/sites-enabled/myweb.io
,有listen 443 ssl
.
在Robo 3T中,我试图建立连接Use SSH tunnel
.我尝试了端口号443
或80
.但它给了我一个错误:Error: Resource temporarily unavailable. Error when starting up SSH session: -13. (Error #35)
有谁知道如何解决这一问题?
我努力更新同一集合的多个文档,这些文档需要将字段添加到 JSON“根”,以及一个名为logs的现有数组的新对象。
我正在尝试这个
db.getCollection('charges').
update({'supports.dest':ObjectId("xyz"),
date:{
$gte: new Date(2017, 11),
$lt: new Date(2017, 12)
},
"status": {$nin : ["Captured"]
}
},
{$set: {"status": "BillingSuspended",
"replacedStatus":"Captured"}
},
{multi:true},
{$push :
{logs : {"replacedStatus" : "Captured" ,
date: new Date ('2017-12-13T22:00:00.000Z')
}
}
}
)
Run Code Online (Sandbox Code Playgroud)
我在下面收到这个错误,我尝试取出 multi:true 但后来我失去了允许我同时更新许多文档的 multi 属性。我想要一个在 Robomongo 上运行的查询。如果你能帮助我,我将不胜感激。
错误:
[Failed to execute script.
Error: Fourth argument must be empty when specifying upsert and multi with an object. :
DBCollection.prototype._parseUpdate@src/mongo/shell/collection.js:522:1
DBCollection.prototype.update@src/mongo/shell/collection.js:552:18
@(shell):1:1]
Run Code Online (Sandbox Code Playgroud)