redis-collections/simple-example
// this example uses fakeredis instead of redis
const redis = require('fakeredis')
// load the store and the collection we will use
const {Store, RedisSet} = require("redis-collections")
// create a store to run the queries
const store = new Store(redis.createClient())
// define a set. it will be stored under the key 'numbers'
const numbers = new RedisSet('numbers')
// add 'two' to the set
await store.promise(numbers.add('two'))
// add 'one' to the set
await store.promise(numbers.add('one'))
// load the set into a list
const list = await store.promise(numbers.getList())
// print the list
return list
no comments