티스토리 뷰

728x90

 

Commonly used MongoDB commands
 
Database Management
  • Create a database : use <database_name>
  • Show the current database : db
  • Show all databases : show dbs
  • Drop a database : db.dropDatabase()

 

Collection Management
  • Create a collection : db.createCollection("<collection_name>")
  • Show all collections : show collections
  • Drop a collection : db.<collection_name>.drop()
 
Document Management
  • Insert a document :
    db.<collection_name>.insertOne(<document>)
    or
    db.<collection_name>.insertMany(<documents>)

  • Find documents :
    db.<collection_name>.find() or db.<collection_name>.findOne(<query>)

  • Update a document :
    db.<collection_name>.updateOne(<query>, <update>)
    or
    db.<collection_name>.updateMany(<query>, <update>)

  • Delete a document :
    db.<collection_name>.deleteOne(<query>)
    or
    db.<collection_name>.deleteMany(<query>)

 

Query Operators
  • $eq : Matches values that are equal to a specified value.
  • $ne : Matches values that are not equal to a specified value.
  • $gt : Matches values that are greater than a specified value.
  • $lt : Matches values that are less than a specified value.
  • $gte : Matches values that are greater than or equal to a specified value.
  • $lte : Matches values that are less than or equal to a specified value.
  • $in : Matches any of the values specified in an array.
  • $nin : Matches none of the values specified in an array.
  • $and : Joins query clauses with a logical AND and returns all documents that match the conditions.
  • $or : Joins query clauses with a logical OR and returns all documents that match the conditions.

The documentation provides comprehensive information on various topics, including installation, getting started, CRUD operations, aggregation, indexes, security, and more.

 

728x90
댓글
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/07   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
글 보관함