field 이름 변경
field type 변경
- MongoDB: How to change the type of a field? - Stack Overflow
- field type info : $type — MongoDB Manual 3.0.4
모든 collection 들에 대한 작업을 할 때
db.getCollectionNames().forEach(function(collname){
var notcol = {
"mycol1" : true,
"mycol3" : true,
"mycol4" : true,
"system.indexes" : true,
"system.users" : true,
}
var doNotExe = notcol[collname] || true;
if(doNotExe){
print(doNotExe)
return;
}
print(collname)
db[collname].update({}, {$rename:{"old_id":"new_id"}}, false, true);
})
참고로, undefined 에 대한 check 를 할 수 없었다. 그래서 false 와 undefined 를 일치시키는 쪽으로 programming 해야 한다.
댓글 없음:
댓글 쓰기