yeecai/front-end-trivia

mongo commands

Opened this issue · 1 comments

Commands:

  1. db.test.find().limit(1).sort({$natural:-1}) find the last inserted one

https://stackoverflow.com/questions/15306916/dynamically-create-collection-with-mongoose

Create new database
https://stackoverflow.com/questions/19474712/mongoose-and-multiple-database-in-single-node-js-project

Get all databases, trying with this one
https://stackoverflow.com/questions/14822550/getting-list-of-all-databases-with-mongoose
https://stackoverflow.com/questions/20117104/mongodb-root-user

root password

mongosh:

Use admin
db.createUser({user:'admin',pwd:'',roles:["root"]})
db.createUser({user:'admin',pwd:'password',roles:["readWrite"]})
show users