Their documentation doesn't clarify this and ChatGPT always give me incorrect code (probably from legacy versions of RavenDB)
I have been using the code below to set the unique constraint, but the unique constraint is not being set even though this is creating a new index. Im using GoLang.
index := ravendb.NewIndexCreationTask("UniqueEmailIndexTask")
index.Map = "from user in docs.Users select new { user.Email }"
emailUniqueIndexDef := index.CreateIndexDefinition()
emailUniqueIndexDef.Name = "UniqueEmailIndex"
emailUniqueIndexDef.Fields = map[string]*ravendb.IndexFieldOptions{
"Email": {
Indexing: ravendb.FieldIndexingExact,
Storage: ravendb.FieldStorageNo,
},
}
err := store.Maintenance().Send(ravendb.NewPutIndexesOperation(emailUniqueIndexDef))