-
Notifications
You must be signed in to change notification settings - Fork 456
Server api
Complete me based on src/server/model.coffee
All these methods operate on documents, except for closeDb
and flushDb
.
-
docName
, the name of the doc to create -
type
, the type of the doc to create -
meta
(optional), ??? -
callback
, called with(error, doc)
-
docName
, the name of the doc to delete -
callback
, called with(error)
WARNING: This isn't well supported throughout the code. E.g.: Streaming clients aren't told about the deletion and subsequent op submissions will fail.
-
docName
, the name of the doc to get ops from -
start
, first op to get -
end
, can be null, which means 'get me all ops from start'. -
callback
, called with(error, ops)
Gets all operations from [start
...end
]. (That is, its not inclusive.)
Each op returned is in the form {op:o, meta:m, v:version}
.
docName
-
callback
, called with(error, {v: <version>, type: <type>, snapshot: <snapshot>, meta: <meta>})
Returns the current state (version, type, content and meta) of this document.
docName
-
callback
, called with(error, version)
docName
-
opData
, the operation to apply -
callback
, called with(error, applied version #)
Applies the OT-op given in opData
the current content of this document, opData
has to be structured like this:
{
op: [{ /* ... */ }], // array of ops to apply (has to be an array)
v: 0, // version to apply the op on
meta: null
}
See JSON-Operations for further documentation of the op
-value.
docName
metaOpData
callback
docName
version
listener
callback
docName
listener
var connect = require(‘connect’), sharejs = require(‘share’).server;
var server = connect( connect.logger(), connect.static(__dirname + ‘/public’) ); var options = {db: {type: ‘none’}}; // See docs for options. {type: ‘redis’} to enable persistance.
// Attach the sharejs REST and Socket.io interfaces to the server sharejs.attach(server, options);
server.listen(8000, function(){ console.log(‘Server running at http://127.0.0.1:8000/’); });*** * ![1000015332](https://github.com/josephg/ShareJS/assets/170631456/cbf03d1e-a278-449a-a0c1-afb388b9a203) *