Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to add indexes to existing collections mongodb

//createIndex adds creates new indexing to existing collections indexes

db.collection.createIndex(
  {
      "a": 1
  },
  {
      unique: true,
      sparse: true,
      expireAfterSeconds: 3600
  }
)
 
PREVIOUS NEXT
Tagged: #add #indexes #existing #collections #mongodb
ADD COMMENT
Topic
Name
9+6 =