Learn how to convert your html into a dynamic realtime application.
CRUD Objects
Simple objects you can use to create custom components.
Create Document Parameters
-
namespace string optional
create namespace
-
rooms string optional
creates room
-
broadcast boolean optional
broadcast or only save to db
-
array string required
array to save to
-
object array object optional
data to save
-
metaData string array object optional
Additonal data in the form of a string , array or object
crud.createDocument({
array: "string",
object: {
name1: "hello"
name2: "hello1"
}
})
Read Document Parameters
-
array string required
array to save to
-
object _id required
object to read from
-
name array optional
names of values to from CMS. If not used whole object will be fetched
-
metaData string array object optional
Additonal data in the form of a string ,array or object
crud.readDocument({
array: "module",
object : {
_id: "",
name: ''
...
}
})
Update Document Parameters
-
namespace string optional
create namespace
-
rooms string optional
creates room
-
broadcast boolean optional
broadcast or only save to db
-
array string required
array to save to
-
object string required
Document _id to save to
-
data object optional
data to save
-
metaData string array object optional
Additonal data in the form of a string , array or object
crud.updateDocument({
array: "test123",
object: {
_id: "object",
name1: "hello",
name2: "hello1"
},
updateName: ["name3", "name4"],
deleteName: ["name3", "name4"],
upsert: true|false //default to true
})
Delete Document Parameters
-
namespace string optional
create namespace
-
rooms string optional
creates room
-
broadcast boolean optional
broadcast or only save to db
-
array string required
array to save to
-
object string required
array to save to
-
data object optional
data to save
-
metaData string array object optional
Additonal data in the form of a string , array or object
crud.deleteDocument({
array: "module",
object: {
_id: ""
}
})
Read Document Filter Parameters
-
array string required
array to save to
-
data object optional
data to save
-
element boolean optional
Save data onChange/submitBtn. If attribute is empty or not used Default's to true.
-
metaData string array object optional
Additonal data in the form of a string , array or object
-
operator object required
The operator object for read object list
-
fetch object optional
{name: the field name for fetching, value: the value for fetching}
If the "fetch" parameter define, result will fetch the items that is [name] = value
-
filters array[object] required
The data structure for each item: {name: string, operator: string, value: array}
name: The field name
operator: Query operator (includes | $range | $eq | $ne | $lt | $lte | $gt | $gte | $in | $nin | $geoWithin)
value: The operator values
-
orders array[object] optional
The data structure for each item: {name: string, type: integer}
name: The field name
type: The order type(-1: desc, 1: asc)
-
search object optional
All fields values search
typestring(or|and): The search type (or | and)
valuearray: The search values
-
index integer required
Set the start index that fetch items. If don't need it, index can define 0
-
count integer optional
Set the count that fetch items. If count didn't defined, it will fetch whole result items
-
-
export boolean optional
If export is true, it will downlod the file about response
crud.readDcoumentList { array: "modules", filter: { query: [{ name: 'field1', value: [v1, v2, ...], operator: "includes | $range | $eq | $ne | $lt | $lte | $gt | $gte | $in | $nin | $geoWithin" }, { name: "_id", opreator: "in", value: ["id1"] } ], sort: [{ name: 'field-x', type: 1 | -1 }], search: { type: 'or | and', value: [value1, value2] }, indexinteger), count: 0 (integer) } -------- response data ----------- object: [] // array
Example:crud.readDocument({ "key": "2061acef-0451-4545-f754-60cf8160", "organization_id": "5ff747727005da1c272740ab", "array": "module_activity", "metadata": "", // TODO: update to new filters "filter": { "query": [ { "name": "color", "value": [ "red", "blue" ], "operator": "in" } ], "sort": [ { "name": "name", "type": 'asc' } ], "search": { "operator": "or", "value": [ "test" ] }, "index": 0, "limit": 20 } })
CRDT Objects
Conflict resolving objects to create collaborative apps.
Init CRDT Parameters
-
namespace string optional
create namespace
-
rooms string optional
creates room
-
broadcast boolean optional
broadcast or only save to db
-
array string required
array to save to
-
data object optional
data to save
-
metaData string array object optional
Additonal data in the form of a string , array or object
crdt.init({
array: "module",
object: "",
name: ""
})
Get Data CRDT Parameters
-
array string required
array to save to
-
data object optional
data to save
-
element boolean optional
Save data onChange/submitBtn. If attribute is empty or not used Default's to true.
-
metaData string array object optional
Additonal data in the form of a string , array or object
crdt.getText({
array: 'module_activities',
object: '5e4802ce3ed96d38e71fc7e5',
name: 'name'
})
Update Data CRDT Parameters
-
array string required
array to save to
-
object _id required
object to insert-crdt from
-
name object optional
data to save
-
value object optional
data to save
-
start object optional
data to save
-
crud object optional
data to save
-
element boolean optional
Save data onChange/submitBtn. If attribute is empty or not used Default's to true.
-
metaData string array object optional
Additonal data in the form of a string , array or object
crdt.updateText({
array: 'module_activities',
object: '5e4802ce3ed96d38e71fc7e5',
name: 'name',
value: 'T',
start: 8,
})
Replace Data CRDT Parameters
-
broadcast boolean optional
broadcast or only save to db
-
array string required
array to save to
-
object string required
array to save to
-
name object optional
name to save
-
value object optional
characters to insert
-
element boolean optional
Save data onChange/submitBtn. If attribute is empty or not used Default's to true.
-
metaData string array object optional
Additonal data in the form of a string , array or object
crdt.replaceText({
array: "module",
object: "",
name: "",
value: "",
})
WebSocket Objects
Send and listen to messages
Create Socket Parameters
-
array string required
array to save to
-
object string required
Document _id to save to
-
name string required
Save data onChange. If attribute is empty or not used Default's to true.
-
start string optional
Save data onChange/submitBtn. If attribute is empty or not used Default's to true.
-
end string array object optional
Additonal data in the form of a string , array or object
socket.create({
namespace: '',
rooms: [r1, r2],
})
Send Message Parameters
-
array string required
array to save to
-
object string required
Document _id to save to
-
name string required
Save data onChange. If attribute is empty or not used Default's to true.
-
start string optional
Save data onChange/submitBtn. If attribute is empty or not used Default's to true.
-
end string array object optional
Additonal data in the form of a string , array or object
socket.send('action', {
namespace: '',
room: '',
broadcast: true/false,
broadcast-sender: true/false
broadcast-browser: true/false
data': {
...
}
})
Listen Message Parameters
-
data string required
array to save to
-
object _id required
object to get-cursor from
-
data object optional
data to save
socket.listen('action', function(data) {
...
})