Joseph Gentle
unread,May 2, 2014, 8:38:06 PM5/2/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sha...@googlegroups.com, derbyjs
Hi all
I've been rewriting the guts of livedb over the last couple weeks, and
I've published livedb 0.4.
IMPORTANT TLDR: If you want to keep using redis, you need to change
how you're initializing livedb with 0.4
There's two important new features you should be aware of:
- Livedb no longer requires redis. Redis is still used as a pub-sub
message bus & single source of truth when you have multiple servers.
But a lot of the time you only have one server. I've factored out &
isolated the redis code behind a driver interface, and added a simple
in-process version of the same API.
If you aren't scaling across multiple servers, you can get rid of your
redis server and remove references to it and everything will keep
working.
If you are using redis, you need to instantiate livedb a little differently:
livedb.createClient({db:snapshotDb, driver:livedb.redisDriver(oplogDb,
redisClient, redisObserver), ...})
If your snapshots and oplog are stored in the same place, pass your
database into both redisDriver and livedb.createClient.
Sorry about the API churn - in another version or two I'll pull the
redis driver entirely out of livedb, and you'll have to change how
you're instantiating everything again.
- Projections! - Here at lever we're sending way too much data to our
clients. I've added a new (experimental) feature to livedb whereby you
can expose a fake collection which maps a few fields from a real
collection. Any operations (gets, queries, sets, etc) on the fake
collection work, but you only see a small portion of the data. You can
use this to drop server & db load dramatically and speed up page
times. I think this is the equivalent to SQL VIEWs. For now, this only
works on JSON documents. (I don't know what it would look like for
text documents).
Its worth noting that you still need to restrict users from making
queries. You can make clever use of queries to find out any data in
hidden fields. If you want to stop people from accessing some of your
data, use sharejs middleware just like before.
Use it by calling:
livedbclient.addProjection("users_small", "users", "json0",
{name:true, age:true});
Limitations:
- You can only whitelist fields (not blacklist them).
- The third parameter must be 'json0'.
- Projections can only limit / allow fields at the top level of the document
- If you're using racer/derby, you should enable {id:true} in the projection.
I've also dramatically increased the test coverage of livedb (I think
there's about 2x as many tests as there were before).
There's still more feature work to do in livedb before I move on to
other areas of my stack. If nothing major comes up, 0.5 should come
out soon.
As always, let me know if you run into any issues.
-Joseph