livedb-postgresql
This is a PostgreSQL adapter for livedb. It does not yet implement the livedb query interface.
Install
npm install --save livedb-postgresql
Schema
Requirements
livedb-postgresql has relatively relaxed requirements for the database it connects to. The table names can be anything, because they're set when creating an instance of livedb-postgresql.
The column names are also configuration, see the inline documentation for examples.
Snapshots Table
Column Name | Type |
---|---|
collection | text |
name | text |
data | json |
Operations Table
Column Name | Type |
---|---|
collection_name | text |
document_name | text |
version | bigint |
data | json |
Example
Here is an example SQL statement that will work with livedb-postgresql:
( collection_name text NOT NULL, name text NOT NULL, data json NOT NULL); ON documents(collection_name, name); ( collection_name text NOT NULL, document_name text NOT NULL, version bigint NOT NULL, data json NOT NULL); ON operations(collection_name, document_name, version);
Usage
var LivePg = ;var livedb = ;var redis = ; // Redis clientsvar redisURL = ;var redisPass = redisURLauth1;var redis1 = redis;var redis2 = redis; // Postgres clientsvar connString = processenvDATABASE_URL;var snapshotDb = conn: connString table: 'documents' ;var opLog = conn: connString table: 'operations' ; var driver = livedb;var liveClient = livedb;
Testing
After creating database tables:
PG_URL=postgres://localhost:5432/livedb-postgresql_test npm test