You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+44-3Lines changed: 44 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,56 @@ Doesn't support queries (yet?).
8
8
Moderately experimental. (This drives [Synaptograph](https://www.synaptograph.com)'s backend, and [@nornagon](https://github.com/nornagon) hasn't noticed any issues so far.)
9
9
10
10
11
+
## Requirements
12
+
13
+
Due to the fix to resolve [high concurency issues](https://github.com/share/sharedb-postgres/issues/1) Postgres 9.5+ is now required.
14
+
15
+
## Migrating older versions
16
+
17
+
Older versions of this adaptor used the data type json. You will need to alter the data type prior to using if you are upgrading.
18
+
19
+
```PLpgSQL
20
+
ALTERTABLE ops
21
+
ALTER COLUMN operation
22
+
SET DATA TYPE jsonb
23
+
USING operation::jsonb;
24
+
25
+
ALTERTABLE snapshots
26
+
ALTER COLUMN data
27
+
SET DATA TYPE jsonb
28
+
USING data::jsonb;
29
+
```
30
+
11
31
## Usage
12
32
13
-
`sharedb-postgres` wraps native [node-postgres](https://github.com/brianc/node-postgres), and it supports the same configuration options.
33
+
`sharedb-postgres-jsonb` wraps native [node-postgres](https://github.com/brianc/node-postgres), and it supports the same configuration options.
14
34
15
35
To instantiate a sharedb-postgres wrapper, invoke the module and pass in your
16
-
PostgreSQL configuration as an argument. For example:
36
+
PostgreSQL configuration as an argument or use environmental arguments.
where v = (select version+1 v from snapshots where collection = $1 and doc_id = $2 for update) or not exists (select 1 from snapshots where collection = $1 and doc_id = $2 for update)
51
+
On conflict(collection, doc_id) do update set version = $3, data = $5 , doc_type = $4
52
+
Returning version
53
+
)
54
+
Insert into ops (collection,doc_id, version,operation)
where (v = (select max(version)+1 v from ops where collection = $1 and doc_id = $2) or not exists (select 1 from ops where collection = $1 and doc_id = $2 for update)) and exists (select 1 from snaps)
0 commit comments