Question

I'm new to sails.js.
I want to issue a redis command on sails-redis like this,

lrange SPECIFIC_KEY 0 10

but I can't see how should I write codes in my model for it.
Documentation for sails-redis and waterline give me no hint to me.

What should I do for this ?

Was it helpful?

Solution

Native Redis commands like LRANGE don't exist at the Waterline ORM level. You'll need to access the underlying node_redis adapter to use them. You can do this using the Waterline collection's native method. If you have a User collection in Sails, for example, it would be:

User.native(function(err, collection) {

   // At this point "collection" is the native node_redis collection
   collection.lrange("someKey", 0, 10, function(err, result) {

       console.log(result);

   });

});

Documentation for the underlying node_redis adapter is here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top