mongodb 的连接命令
到mongodb的安装bin下执行 ./mongo (默认本地ip+默认端口)
mongodb 导出成json文件
mongoexport –db gateway –collection application_log –out C:\Users\dell\Downloads\abc.json
cd D:\Program Files\MongoDB\Server\4.0\bin
导出1000条数据到application_log.json文件中
./mongoexport -h 127.0.0.1 -d gateway -c application_log -o C:\Users\dell\Downloads\application_log.json
导出1000条数据到b.json文件中
./mongoexport -h 127.0.0.1 -d gateway -c service_log –limit 1000 -o C:\Users\dell\Downloads\b.json
导入文件a.json中的数据
./mongoimport -h 127.0.0.1 –db gateway –collection application_log –file C:\Users\dell\Downloads\a.json
批量删除表中is_del = 1的字段
db.getCollection(‘application_log’).update(
// query
{
},
// update
{
$unset:{'is_del': 1}
},
// options
{
"multi" : true, // update only one document
"upsert" : true // insert a new document, if no existing document match the query
}
);