monggoDb使用
插入嵌套字典
数据集代码
{
"_id": 3,
"project_id": 1,
"col_id": 1,
"case_id": 3,
"name": "镇上",
"city": {
"key1": {
"value": "Python",
"enable": true
},
"key2": {
"value": "上海",
"enable": true
}
},
"enable": true,
"add_time": 1573125486,
"up_time": 1573129764,
"__v": 0
}
修改代码:
db.params_excel.update({"_id": 3},{$set:{'city.key1.value':'MongoDB'}})
修改成功显示:
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
修改后的数据:
{
"_id": 3,
"project_id": 1,
"col_id": 1,
"case_id": 3,
"name": "镇上",
"city": {
"key1": {
"value": "MongoDB",
"enable": true
},
"key2": {
"value": "上海",
"enable": true
}
},
"enable": true,
"add_time": 1573125486,
"up_time": 1573129764,
"__v": 0
}
- 数据导出导入
# 导出
mongodump -h 127.0.0.1:27017 -d 导出的数据库 -o 导出的路径 --forceTableScan
# 导入
mongorestore -h 127.0.0.1:27017 -d 导入的数据库 导入路径