Восстановить из дампа mongodb
Импортировать BSON бэкап в MongoDB
mongorestore --uri='mongodb://user:pass@mongo:27017' --db=mydb /backups/mydb/
more mongodb
all 20 commands →
Список индексов
mongosh --eval 'db.myCollection.getIndexes()' mongodb://mongo:27017/mydb
Подключиться по URI
mongosh 'mongodb+srv://user:pass@cluster.example.com/mydb'
План выполнения запроса
db.orders.find({status:'new'}).explain('executionStats')
Создать составной индекс
db.orders.createIndex({userId: 1, createdAt: -1}, {background: true})
Пример aggregation pipeline
db.orders.aggregate([{$match:{status:'paid'}},{$group:{_id:'$userId',total:{$sum:'$amount'}}},{$sort:{total:-1}},{$limit:10}])