Reputation: 28424
I am using sails-redis
adapter. How can I set a secondary index for an attribute in a model and fetch the data accordingly?
Upvotes: 0
Views: 230
Reputation: 31
I haven't used the Sails Redis adapter, so take my advice with a grain of salt. Based on their public documentation, it seems like it does not support any form of indexing - it's just a wrapper around the core Redis commands:
This adapter does not support the Semantic or Queryable interfaces. Instead, it simply provides robust, managed access to the underlying Redis client.
Source: https://www.npmjs.com/package/sails-redis
As such, you'll have to manually create secondary indices. Redis provides a number of data structures that come in handy here, such as sorted sets, sets, and lists.
I wrote a bit of an article about how to create those indices, which might be a useful read.
Upvotes: 1