DB/MongoDB
[mongo] 전체 컬럼 업데이트
벨포트조던
2022. 5. 2. 17:24
반응형
배경
- 몽고DB 에서 조회된 data의 특정 컬럼에 특정 문자열을 앞 뒤로 붙이려고 한다
예 )
mno : "1000"
->
mon : "pre1000"
이렇게 ..
참고문서
MongoDB: Problems using $concat to update the value of a field
I'm trying to update the value of a field in a MongoDB collection by concatenating it with a literal string. Besides this, the field is an integer, and I want to add a "0" in front, so it will beca...
stackoverflow.com
db.getCollection("mtable")
.find({ "kno" : {
"$lt" : NumberInt(40000000)
} })
.forEach( function(i) {
db.getCollection("mtable").update(
{ _id: i._id },
{ $set: { "kno": NumberInt("10" + i.UNO) } }
)
});
반응형