Iridium
Iridium copied to clipboard
Creating unique indexes
Is there any other settings required for adding unique indexes. I tried both methods below but no luck. Running a db.users.getIndexes() does not show the unique index in mongodb. I am running the latest code 8.0.0-alpha.4 since I hit this issue https://github.com/SierraSoftworks/Iridium/issues/90.
@Iridium.Index({ email: 1 }, { unique: true })
static indexes = [ { spec: { email: 1 }, options: { unique: true } } ];
Hi @mas-dude, I suspect the issue is that you're not calling Model.ensureIndexes
at any point.
There's a particularly good set of examples in #80 and my answer there.
I still haven't gotten around to updating the documentation to clarify this, so I apologise for the confusion.
Thanks, yes that was it. Sorry I should have looked through the previous issues a bit more before asking the question. Would be nice to have it in the examples even as a comment would be fine. I have been following https://github.com/SierraSoftworks/Iridium/blob/release/example/UserModel.ts. Are there any other samples worth looking at?
Thanks again.