몽고DB
CRUD - Update
NaHyungMin
2017. 4. 24. 17:06
1. 조건 없이 전체 데이터를 변경하고 싶을 때
db.getCollection('데이터베이스 명').update(
// query
{
},
{$set: {해당 컬럼 명: NumberInt(500000)}}, //Int로 데이터를 변경
// options
{
"multi" : true, // update only one document
"upsert" : false // insert a new document, if no existing document match the query
}
);
2. id가 1번인 유저의 정보를 변경하고 싶을 때
db.getCollection('user_game_data').update(
// query
{
"id":1
},
{$set: {해당 컬럼 명: NumberInt(500000)}}, //Int로 데이터를 변경
// options
{
"multi" : true, // update only one document
"upsert" : false // insert a new document, if no existing document match the query
}
);