Iridium icon indicating copy to clipboard operation
Iridium copied to clipboard

Creating unique indexes

Open mas-dude opened this issue 7 years ago • 2 comments

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 } } ];

mas-dude avatar Sep 14 '17 11:09 mas-dude

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.

notheotherben avatar Sep 14 '17 21:09 notheotherben

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.

mas-dude avatar Sep 14 '17 23:09 mas-dude