show collections in mongodb
db.getCollectionNames()
mongodb cmds
MongoDB
mongod --dbpath /users/yulin/Documents/data/db
mongo (once mongod is ran OPEN ANOTHER TERMINAL THconnect to MongoDB)
ctrl-l to clear screen
show dbs
use {put db name here}
show collections
use {put collection name here} ex. - use quizzes
use dbs ( or cd .. -- to go back dbs level)
or just stay @ db level
db.createCollection(“quizzes”)
db.quizzes.find().pretty()
db.quizzes.insert({“title”: 1}) (crud stuff)
db.quizzes.find({“title”: 1})
db.quizzes.remove({}) (remove all)
db.quizzes.remove({title: 1})
db.quizzes.update ({title: 1}, {title, 2}) (update by replaceing the entire object)
db.quizzes.update ({name: “yulin”}, {$set:{title: “Quiz 2”}}) (update by appending object)
db.quizzes.find({avg: {$gt: 85}}) (greater than)
db.quizzes.find({avg: {$gte: 85}}) (greater than or equal to)
db.quizzes.find({avg: {$lte: 85}}) (less than)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us