Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

support for hashed indexes, and compound indexes #212

Open
devendrapratap02 opened this issue Jun 11, 2018 · 2 comments
Open

support for hashed indexes, and compound indexes #212

devendrapratap02 opened this issue Jun 11, 2018 · 2 comments

Comments

@devendrapratap02
Copy link

Hi, in this issues, #9 (comment)

How can I create hashed index, and compound indexes in models.

An example would be great.

Thanks

@vadimdemedes
Copy link
Owner

Don't know to be honest, never used them. If you were able to find a solution or know what needs to be done in order to support this, feel free to reply here with your findings or submit a PR.

@ambrons
Copy link

ambrons commented May 2, 2019

I know this is nearly a year old, but figured I'd put my thoughts here. Hopefully if my understanding is wrong someone will correct me.

Digging through the code that createIndex method of the Model class uses redux-like dispatch (as the project states) which is processed by the create-index middleware. This in turns uses the call middleware which at a high level is the connection to the mongo driver. So in short reading the documentation for the mongo-native-driver for createIndex
You should be able to do the following for a compound index

Post.createIndex({fielda:1, fieldb:1}, {unique: true});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants