MongoDB set of study notes _2_

Set operations

MongoDB concept equivalent to the set of SQL table concept.

  • Create Collection
    1. db.createCollextion()
    2. When you insert a document to a collection, if the collection does not exist, it is automatically createddb.collection_name.insert()
  • A set of naming conventions
    1. It can not be an empty string
    2. Not contain '\ 0'
    3. Not start with a system, which is reserved prefix collection system
    4. Do the same name and a set of reserved words do not include $
  • View the collection database
    • show tablesorshow collections
  • Delete Collection
    • db.collection_name.drop()
  • Modify the collection name
    • db.collection_name.renameCollection('newName')
      • eg class1 will be renamed class0 db.class1.renameCollection('class0')
  • Gets a collection of objects
    • db.collection_name
    • db.getCollection('collection_name')

Guess you like

Origin www.cnblogs.com/donyblog/p/11668156.html