mlab/mongodb에서 이러한 ID 중 하나를 자동 생성하지 못하게하려면 어떻게합니까?E11000 중복 키 오류 색인 - mlab에서 자동 생성 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 객체가 바람직합니다.
db.collectioName.update({"key":{"$exists":true}},{"$unset":{"key":""}},
{"upsert":false,"multi":true})
unset
key
을 제거 :
이상한 것은, 내가 데이터베이스에서 볼 때 나는 단지이
{
"_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을
'_id' 또는'key' 필드 만 제거 하시겠습니까? – Yogesh
키 필드가 바람직합니다 –