orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift
MIT License
717 stars 102 forks source link

Create unique index with multiple fields #304

Closed JohnCoates closed 1 year ago

JohnCoates commented 1 year ago

Is your feature request related to a problem? Please describe.

Is it currently possible to build a unique index with multiple fields? I looked at the following code but it didn't look like I could do that. https://github.com/orlandos-nl/MongoKitten/blob/c82d7be854ce9a16d0eb3d0f6fd30b4b8c55e9aa/Sources/Meow/Indexes.swift#L27-L33

Describe the solution you'd like Would be great to add a unique index with multiple fields.

Describe alternatives you've considered None.

Additional context N/A

Joannis commented 1 year ago

Hey, thanks for highlighting this! MongoKitten 7 has a couple of helpers already, but I don't think I'll add overrides for each and every possible scenario. However, I propose adding an override on SortedIndex that accepts multiple fields, which you can then mark as unique using the .unique() function on that index.

JohnCoates commented 1 year ago

That sounds like a good solution.

Joannis commented 1 year ago

fixed in 7.2.14