Adding compound, unique index with MongoDB can be done as follows:
db.collection.ensureIndex( { column-1 : 1, column-2 : 1 }, { unique : true } )
To achieve the same using Spring Data, use the following annotations:
@CompoundIndexes({
@CompoundIndex(name = "my_index_name",
unique = true,
def = "{'column-1' : 1, 'column-2' : 1}")
})
I want to create index with "expireAfterSeconds" property. what syntax should be used?
ReplyDelete