E11000 重复键错误索引 - 从 mlab 中删除自动生成的 ID
E11000 duplicate key error index - Removing auto generated ID from mlab
如何让 mlab/mongodb 停止自动生成这些 ID 之一?
key: { : ObjectId('584f7e76fd51ea874cee3c70') }",
"op":{"title":"Gold (feat. Lil Wayne) (Remix)",
"artist":"kiiara",
"audio":"https://api.soundcloud.com/tracks/293663905/stream?client_id=90d140308348273b897fab79f44a7c89",
"image":"https://i1.sndcdn.com/artworks-C09aBfgKDpCI-0-t500x500.jpg",
"download":"https://api.soundcloud.com/tracks/293663905/download",
"url":"https://soundcloud.com/kiiaraonline/gold-lil-wayne-remix",
"created":"2016-12-13T04:52:06.309Z",
"genres":{"hipHop":30,"house":20,"pop":50},
"_id":"584f7e76fd51ea874cee3c70"}
当我尝试创建关系时,我收到一条错误消息,指出有两个键。我认为这是因为有两个 ID。我怎样才能删除其中一个?最好是 ObjectId 之一。
奇怪的是,当我在数据库中查看它们时,我只看到这个
{
"_id": {
"$oid": "584f7e76fd51ea874cee3c70"
},
"title": "Gold (feat. Lil Wayne) (Remix)",
"artist": "kiiara",
"audio": "https://api.soundcloud.com/tracks/293663905/stream?client_id=90d140308348273b897fab79f44a7c89",
"image": "https://i1.sndcdn.com/artworks-C09aBfgKDpCI-0-t500x500.jpg",
"download": "https://api.soundcloud.com/tracks/293663905/download",
"url": "https://soundcloud.com/kiiaraonline/gold-lil-wayne-remix",
"created": {
"$date": "2016-12-13T04:52:06.309Z"
},
"genres": {
"hipHop": 30,
"house": 20,
"pop": 50
}
}
谢谢
在更新中使用 $exists 如下:
db.collectioName.update({"key":{"$exists":true}},{"$unset":{"key":""}},
{"upsert":false,"multi":true})
unset
删除所有匹配文档中的 key
个字段。
如何让 mlab/mongodb 停止自动生成这些 ID 之一?
key: { : ObjectId('584f7e76fd51ea874cee3c70') }",
"op":{"title":"Gold (feat. Lil Wayne) (Remix)",
"artist":"kiiara",
"audio":"https://api.soundcloud.com/tracks/293663905/stream?client_id=90d140308348273b897fab79f44a7c89",
"image":"https://i1.sndcdn.com/artworks-C09aBfgKDpCI-0-t500x500.jpg",
"download":"https://api.soundcloud.com/tracks/293663905/download",
"url":"https://soundcloud.com/kiiaraonline/gold-lil-wayne-remix",
"created":"2016-12-13T04:52:06.309Z",
"genres":{"hipHop":30,"house":20,"pop":50},
"_id":"584f7e76fd51ea874cee3c70"}
当我尝试创建关系时,我收到一条错误消息,指出有两个键。我认为这是因为有两个 ID。我怎样才能删除其中一个?最好是 ObjectId 之一。
奇怪的是,当我在数据库中查看它们时,我只看到这个
{
"_id": {
"$oid": "584f7e76fd51ea874cee3c70"
},
"title": "Gold (feat. Lil Wayne) (Remix)",
"artist": "kiiara",
"audio": "https://api.soundcloud.com/tracks/293663905/stream?client_id=90d140308348273b897fab79f44a7c89",
"image": "https://i1.sndcdn.com/artworks-C09aBfgKDpCI-0-t500x500.jpg",
"download": "https://api.soundcloud.com/tracks/293663905/download",
"url": "https://soundcloud.com/kiiaraonline/gold-lil-wayne-remix",
"created": {
"$date": "2016-12-13T04:52:06.309Z"
},
"genres": {
"hipHop": 30,
"house": 20,
"pop": 50
}
}
谢谢
在更新中使用 $exists 如下:
db.collectioName.update({"key":{"$exists":true}},{"$unset":{"key":""}},
{"upsert":false,"multi":true})
unset
删除所有匹配文档中的 key
个字段。