2011年12月8日 星期四

[MongoDB] update one field of all records 更新所有資料裡的某個欄位

Usage: db.collection.update( criteria, objNew, upsert, multi )

MongoDB shell:
> db.users.update({}, {$set : { subscribe : true }}, false, true)

[MongoDB] print one field of all record 列出所有資料裡的某個欄位

MongoDB Shell:

> db.users.find({}, {email:1}).forEach(function(u) {print(u.email)})
Related Posts Plugin for WordPress, Blogger...