0.4.0 • Published 6 years ago
resolve-readmodel-redis v0.4.0
resolve-readmodel-redis
This package is a resolve-query
adapter for storing a read model in Redis store. The adapter is based on the Redis client.
The store interface is implemented using the resolve-readmodel-redis
adapter and provides segregated read and write access:
- Read access is used to retrieve data from a store (for example, by a graphql resolver). The package provides the
hget(key, field)
asynchronous method to get the value associated with thefield
from the hash stored at thekey
. - Projection functions use Write access to update data. The following asynchronous methods are available:
hset(key, field, value)
- sets thevalue
associated with thefield
in the hash stored atkey
;del(key)
- deletes the hash stored at thekey
. Does nothing if thekey
does not exist.
Usage
import createRedisAdapter from 'resolve-readmodel-redis';
import { createReadModel } from 'resolve-query';
const adapter = createRedisAdapter();
const testEventStore = {
subscribeByEventType: (_, handler) => Promise.resolve(
handler({ type: 'TestEvent', text: 'One' }),
handler({ type: 'TestEvent', text: 'Two' })
)
};
const executeReadModel = createReadModel(
eventStore: testEventStore,
adapter,
projection: {
Init: async (store) => {
await store.hset('Test', 'myField', { changeCount: 0, text: 'Initial' })
},
TestEvent: async (store, event) => {
const value = await store.hget('Test', 'myField');
const newValue = {
changeCount: value.changeCount + 1,
text: event.text
};
await store.hset('Test', 'myField', newValue);
}
}
)
const store = await executeReadModel();
const value = store.hget('Test', 'myField');
console.log(value)
0.5.0-beta.3
6 years ago
0.5.0-beta.2
6 years ago
0.4.1-130082009.beta
6 years ago
0.4.1-126112217.beta
6 years ago
0.4.1-126102017.beta
6 years ago
0.4.1-124150149.beta
6 years ago
0.4.1-124150146.beta
6 years ago
0.4.1-124084142.beta
6 years ago
0.4.1-124080800.beta
6 years ago
0.4.1-123154100.beta
6 years ago
0.4.1-123152459.beta
6 years ago
0.4.0
6 years ago
0.2.3-123151035.beta
6 years ago
0.2.3-123143953.beta
6 years ago
0.2.3-123142027.beta
6 years ago
0.2.3-123135820.beta
6 years ago
0.2.3-123135201.beta
6 years ago
0.2.3-123133524.beta
6 years ago
0.2.3-123132620.beta
6 years ago
0.2.3-123130038.beta
6 years ago
0.2.3-123124119.beta
6 years ago
0.2.3-123094423.beta
6 years ago
0.2.3-122162216.alpha
6 years ago
0.2.3-122120359.alpha
6 years ago
0.2.3-122072346.beta
6 years ago
0.2.3-119165532.alpha
6 years ago
0.2.3-119164548.alpha
6 years ago
0.2.3-119163508.alpha
6 years ago
0.2.3-119161651.alpha
6 years ago
0.0.1-119161449.alpha
6 years ago
0.2.3-119091449.beta
6 years ago
0.2.3-118133333.beta
6 years ago
0.2.3-118105442.beta
6 years ago
0.3.0-alpha.ff3e3a77
6 years ago
0.3.0-alpha.f0943ac4
6 years ago
0.3.0-alpha.a8bfd927
6 years ago
0.3.0-alpha.6328a182
6 years ago
0.3.0-alpha.4822f501
6 years ago
0.3.0-alpha.a4264b2a
6 years ago
0.3.0-alpha.a508c6f7
6 years ago
0.3.0-alpha.e1c431e5
6 years ago
0.3.0-alpha.71f5a33f
6 years ago
0.2.2-alpha.1228084441
6 years ago
0.2.2-alpha.1226074522
6 years ago