If you're using ShareJS 0.6, upgrade to ShareDB 1.0 for:
- stability and future improvement
- ability to run with multiple processes (coordinated via Redis)
- queries
If you're using ShareJS 0.7, upgrade to ShareDB 1.0 for stability and future improvements.
This document describes the database and API changes from ShareJS 0.7 to ShareDB 1.0
The way snapshots are stored in the database hasn't changed, other than one
small detail: The '_o'
property is now reserved as a pointer to the last
operation committed on the snapshot. Snapshots that lack the '_o'
property
will continue to work fine, but make sure to remove any application-level
'_o'
properties.
The way ops are stored in the database has changed between ShareJS 0.7 and ShareDB 1.0. The tl;dr is: Don’t try to migrate your ops.
Here’s the longer story: ShareJS used Redis for the commit process, and only one op was stored in the database for each version. ShareDB can potentially store more than one op for each version but only one of them is pointed to from the snapshot itself. Snapshots without ops work totally fine, unless you're doing something particular with the ops history.
The ShareDB API is documented in the main README. When unsure, look there.
The code to start a server instance and client has changed. See the main README for more information.
The following methods have been replaced by methods on the client API:
livedb.submit()
, replaced bydoc.submitOp()
anddoc.delete()
livedb.subscribe()
andlivedb.fetchAndSubscribe
, replaced bydoc.subscribe()
livedb.bulkSubscribe()
, replaced byconnection.startBulk(); ...; connection.endBulk()
. Currently undocumentedlivedb.queryFetch()
andlivedb.querySubscribe()
, replaced byconnection.createFetchQuery()
andconnection.createSubscribeQuery()
The following methods have been replaced by methods directly on the database adapter
livedb.fetch
, replaced bydb.getSnapshot()
livedb.bulkFetch
, replaced bydb.getSnapshotBulk()
livedb.getOps
, replaced bydb.getOps()
And a few more changes:
addProjection()
no longer takes an OT type in the third argumentbuildSnapshot()
is no longer available.
doc.snapshot
replaced bydoc.data
doc.state
is no longer availabledoc.name
replaced bydoc.id
doc.getSnapshot()
replaced bydoc.data
doc.whenReady(...)
replaced bydoc.on('load', ...)
doc.create()
changed arguments: (data, type, ...) instead of (type, data, ...)doc.on()
:after op
replaced byop
created
replaced bycreate
subscribed
replaced byload
connection.disconnect()
replaced byconnection.close()
connection.getOrCreate()
no longer takes in optional inital data. Instead, calldoc.ingestSnapshot
.
new Query
: first argument is now'fetch'
or'sub'
instead of'qf'
or'qs'
query.setQuery
is no longer available
- No more middleware actions for
'fetch'
,'submit'
,'subscribe'
,'get ops'
,'query'
. - There's a new action called
'receive'
that fires on all client actions. 'filter()'
is replaced by the middleware action'doc'
'filterOps()'
is replaced by the middleware action'op'
- Changes to request properties:
- No more
req.backend
— instead, look atreq.agent.backend
req.docName
replaced byreq.id
- No more
agent.trigger()
is nowshare.trigger()
- Generally, don’t use the Agent API directly — instead create a client