===== CRUD =====
[[https://docs.mongodb.com/manual/crud/|MongoDB CRUD 操作]]
=== 删除数据 ===
db.collection.deleteOne({id:xxx})
=== 删除某个时间点前的数据 ===
# 查看要删除的数量
db.collection.find({"create_time":{$lt:(NumberLong(new Date("2020-10-01"))/1000)}}).count()
# 执行删除
db.collection.deleteMany({"create_time": {$lt: (NumberLong(new Date("2020-10-01"))/1000)}})
# 确认删除成功
db.collection.find({"create_time":{$lt:(NumberLong(new Date("2020-10-01"))/1000)}}).count()
=== 删除某个时间点前的数据(老版api) ===
db.hover_info.remove({"create_time": {$lt:1604160000}})
===== 用户与权限 =====
=== 查看当前登录的用户 ===
db.runCommand({connectionStatus : 1})
=== 登录用户(进入 mongo 后) ===
use xxdb
db.auth("admin","adminPassword")