Common commands for MongoDB and Common commands for mongodb
Common commands for MongoDB Databases
Show dbs # show database use test # select/create database db. dropDatabase () # Delete the current database db # display the current database db. test_col.insert ({x: 1}) # insert (create set) var_insert = {a: 1, B: 3} db. test_col.insert (var_insert) # insert db as a variable. test_col.drop () # Delete the test_col Collection show collections # display the collection db. test_col.find () # query all data. The id field is automatically generated and can be specified, but it cannot be repeated. test_col.find ({y: 1}) # query the specified database. test_col.find (). count () # count for (I = 3; I <10; I ++) db. test_col.insert ({x: I}) # supports shell loop db. test_col.find (). skip (2 ). limit (3 ). sort ({x: 1}) # Skip, limit, and sort db. test_col.update ({x: 1}, {$ set: {x: 10}) # update, $ set: partially updated x