0.2.2 • Published 10 years ago
falcor-ioredis v0.2.2
falcor-ioredis
What is this?
Falcor-ioredis is a simple piece of middleware that uses the Falcor-model to sync with a JSON Graph stored in a Redis database. If references are found, redis will be queried automatically for the references.
Installation
$ npm install falcor-ioredis
'use strict';
var EXPRESS = require('express'),
FALCORIOREDIS = require('falcor-ioredis'),
FALCORSERVER = require('falcor-express'),
FALCOR = require('falcor'),
EXPRESS = require('express'),
APP = EXPRESS();
APP
.use('/', function(req, res){
var falcorIoredis = new FALCORIOREDIS('redis://localhost:6379', req, function(resultModel){
var falcorModel = new FALCOR
.Model(resultModel) ;
var dataSourceRoute = FALCORSERVER
.dataSourceRoute(function(req, res) {
return falcorModel
.asDataSource();
});
dataSourceRoute(req,res);
});
});
var server = APP
.listen(8080, function(err) {
if (err) console.error(err);
console.log('JSON graph available on http://localhost:8080');
});
How does it work?
Json Graph example:
{
"somethingById": {
"a": {
"foo": "bar"
},
"b": {
"foo": {
"$type": "ref",
"value": "valuesById[c]"
}
}
},
"valuesById": {
"c": {
"foo": "baz"
}
}
}
The above example will be stored like this in Redis:
HSET somethingById a '{"foo":{$type:"ref","value":"valuesById[a]"}}'
HSET somethingById b '{"foo":{"$type":"ref","value":"valuesById[c]"}}'
HSET valuesById c '{"foo":"baz"}'
Model request for: //localhost/?paths=[["somethingById","a","foo"]]&method=get
will return:
{
"jsonGraph": {
"somethingById": {
"a": {
"foo": {
"$type": "atom",
"value": "bar",
"$modelCreated": true,
"$size": 3
}
}
}
},
"paths": [
[
"somethingById",
"a",
"foo"
]
]
}
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.2
10 years ago
0.1.1
10 years ago
0.1.0
10 years ago
0.0.12
10 years ago
0.0.11
10 years ago
0.0.10
10 years ago
0.0.9
10 years ago
0.0.8
10 years ago
0.0.7
10 years ago
0.0.6
10 years ago
0.0.5
10 years ago
0.0.4
10 years ago
0.0.3
10 years ago
0.0.2
10 years ago
0.0.1
10 years ago