【发布时间】:2015-05-06 05:15:45
【问题描述】:
我是 NoSQL 数据库的新手,使用的是 Mongo 2.4.12 版。我有一个名为“user”的集合,我想添加一个名为“useremail”的新字段。能否请您告诉我如何从命令行/shell 终端执行此操作?
> db.user.find({username :"John"}).pretty();
{
"_id" : "ajd233d-u980-4000-92b6-5353e9602502",
"username" : "John",
"password" : "John",
"firstname" :"John",
"lastname" : "Rogers",
"enabled" : true,
"employeeauth" : [
{
"employeeId" : "a2fg190-b50d-14k2-aan0-ebb7298fa2b7",
"authorities" : [
"DEVELOPER", "TESTER", "CONSULTANT"
]
}
],
}
我想添加新字段“useremail”,所以结果显示如下:
> db.user.find({username :"John"}).pretty();
{
"_id" : "ajd233d-u980-4000-92b6-5353e9602502",
"username" : "John",
"password" : "John",
"firstname" :"John",
"lastname" : "Rogers",
"useremail": "john.rogers@test.com",
"enabled" : true,
"employeeauth" : [
{
"employeeId" : "a2fg190-b50d-14k2-aan0-ebb7298fa2b7",
"authorities" : [
"DEVELOPER", "TESTER", "CONSULTANT"
]
}
],
}
【问题讨论】:
标签: mongodb