Documents

Maintainer:Jorin Vogel h.nosp@m.i@jori.nosp@m.n.in
Version:0.1.3

This modue stores lists of documents.  A document has the fields title, content and lastEdited.

Summary
Documents
Schemas
documents/textA text document
Functions
privateListList all private documents.
publicListList all public documents.
listMethods
Functions
addCreate a new document
setUpdate or create a document for a specified id.
removeRemove a document for a specified id.
getGet a document.
addRawStore a raw document of the specified contentType at shared/.
setRawStore a raw doccument of the specified contentType at shared/.

Schemas

documents/text

A text document

Properties

titletitle of the document (string, required)
contentcontent of the document (string, required)
lastEdited13-digit timestamp for when the document was last edited

Functions

privateList

privateList: function(path)

List all private documents.

Parameters

patha pathstring where to scope the client to.

Returns

A privateClient scoped to the given path and extended with the listMethods.  It also supports all BaseClient methods

publicList

publicList: function(path)

List all public documents.

Parameters

patha pathstring where to scope the client to.

Returns

A publicClient scoped to the given path and extended with the listMethods.  It also supports all BaseClient methods

listMethods

Summary
Functions
addCreate a new document
setUpdate or create a document for a specified id.
removeRemove a document for a specified id.
getGet a document.
addRawStore a raw document of the specified contentType at shared/.
setRawStore a raw doccument of the specified contentType at shared/.

Functions

add

add: function(doc)

Create a new document

Parameters

docthe document data to store as JSON object.

Returns

A promise, which will be fulfilled with the created document as JSON object.  The created document also contains the newly created id property.

set

set: function(id,
doc)

Update or create a document for a specified id.

Parameters

idthe id the document is at.
docthe document data to store as JSON object.

Returns

A promise, which will be fulfilled with the updated document.

remove

remove: function(id)

Remove a document for a specified id.

Parameters

idthe id the document is at.

Returns

A promise, which will be fulfilled when the change was made locally.  After that, the change will propagate from local to remote through asynchronous synchronization.

get

get: function(id)

Get a document.

Parameters

idthe id of the document you want to get.

Returns

A promise, which will be fulfilled with the document as JSON object.

addRaw

addRaw: function(contentType,
data)

Store a raw document of the specified contentType at shared/.

Parameters

contentTypethe content type of the data (like ‘text/html’).
datathe raw data to store.

Returns

A promise, which will be fulfilled with the path of the added document.

setRaw

setRaw: function(id,
contentType,
data)

Store a raw doccument of the specified contentType at shared/.

Parameters

idid of the document to update
contentTypethe content type of the data (like ‘text/html’).
datathe raw data to store.

Returns

A promise, which will be fulfilled with the path of the added document.

privateList: function(path)
List all private documents.
publicList: function(path)
List all public documents.
add: function(doc)
Create a new document
set: function(id,
doc)
Update or create a document for a specified id.
remove: function(id)
Remove a document for a specified id.
get: function(id)
Get a document.
addRaw: function(contentType,
data)
Store a raw document of the specified contentType at shared/.
setRaw: function(id,
contentType,
data)
Store a raw doccument of the specified contentType at shared/.
Close