<!-- First JQuery, Bootstrap, etc, ... -->
<script src="https://parentchilddemo-62ef.restdb.io/rest/_jsapi.js"></script>
...
Note that this requires web enabled API-key or a valid JWT token (options.jwt must be set as true). Also note that access restrictions (method, path, events) could prevent this connection from receiving or sending data.
var db = new restdb("your-apikey-here | jwt token", options);
var obj = new db.department(properties);
var instance = new db.department({"name": "value", ...});
name | type | description |
---|---|---|
obj['name']
|
text | - missing description - |
obj['manager']
|
people | - missing description - |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
obj['employees'].addChild(childobj, callback)
var child = new db.people({... properties ...});
obj.addChild(child, function(err, res){
if (!err){
// res is the saved child
}
});
obj['employees'].getChild(callback)
obj.getChild(function(err, res){
if (!err){
// res is an array of child people objects
}
});
db.department.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.department.find(query, hints, function(err, res){
if (!err){
// res is an array of department instances
}
});
db.department.getById(ID, callback)
db.department.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a department instance
}
});
db.department.on(evt, callback)
db.department.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "department", data: "ID"}
// POST: {event: "post", collection: "department", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "department", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.people(properties);
var instance = new db.people({"name": "value", ...});
name | type | description |
---|---|---|
obj['name']
|
text | - missing description - |
obj['email']
|
- missing description - | |
obj['position']
|
option | - missing description - |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
db.people.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.people.find(query, hints, function(err, res){
if (!err){
// res is an array of people instances
}
});
db.people.getById(ID, callback)
db.people.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a people instance
}
});
db.people.on(evt, callback)
db.people.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "people", data: "ID"}
// POST: {event: "post", collection: "people", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "people", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.company(properties);
var instance = new db.company({"name": "value", ...});
name | type | description |
---|---|---|
obj['name']
|
text | - missing description - |
obj['description']
|
text | - missing description - |
obj['manager']
|
people | - missing description - |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
obj['departments'].addChild(childobj, callback)
var child = new db.department({... properties ...});
obj.addChild(child, function(err, res){
if (!err){
// res is the saved child
}
});
obj['departments'].getChild(callback)
obj.getChild(function(err, res){
if (!err){
// res is an array of child department objects
}
});
db.company.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.company.find(query, hints, function(err, res){
if (!err){
// res is an array of company instances
}
});
db.company.getById(ID, callback)
db.company.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a company instance
}
});
db.company.on(evt, callback)
db.company.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "company", data: "ID"}
// POST: {event: "post", collection: "company", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "company", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.systemjobs(properties);
var instance = new db.systemjobs({"description": "value", ...});
name | type | description |
---|---|---|
obj['description']
|
text | Job description |
obj['crontab']
|
text | Crontab expression |
obj['script']
|
text | JavaScript code for job |
obj['active']
|
bool | job is paused (created by system) |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
db.systemjobs.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.systemjobs.find(query, hints, function(err, res){
if (!err){
// res is an array of systemjobs instances
}
});
db.systemjobs.getById(ID, callback)
db.systemjobs.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a systemjobs instance
}
});
db.systemjobs.on(evt, callback)
db.systemjobs.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "systemjobs", data: "ID"}
// POST: {event: "post", collection: "systemjobs", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "systemjobs", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.systemlog(properties);
var instance = new db.systemlog({"status": "value", ...});
name | type | description |
---|---|---|
obj['status']
|
text | Log status |
obj['logstring']
|
text | Log output |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
db.systemlog.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.systemlog.find(query, hints, function(err, res){
if (!err){
// res is an array of systemlog instances
}
});
db.systemlog.getById(ID, callback)
db.systemlog.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a systemlog instance
}
});
db.systemlog.on(evt, callback)
db.systemlog.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "systemlog", data: "ID"}
// POST: {event: "post", collection: "systemlog", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "systemlog", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.emailoutbound(properties);
var instance = new db.emailoutbound({"to": "value", ...});
name | type | description |
---|---|---|
obj['to']
|
email to address (created by system) | |
obj['subject']
|
text | email subject (created by system) |
obj['body']
|
richtext | mail body (created by system) |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
db.emailoutbound.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.emailoutbound.find(query, hints, function(err, res){
if (!err){
// res is an array of emailoutbound instances
}
});
db.emailoutbound.getById(ID, callback)
db.emailoutbound.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a emailoutbound instance
}
});
db.emailoutbound.on(evt, callback)
db.emailoutbound.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "emailoutbound", data: "ID"}
// POST: {event: "post", collection: "emailoutbound", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "emailoutbound", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.emailinbound(properties);
var instance = new db.emailinbound({"from": "value", ...});
name | type | description |
---|---|---|
obj['from']
|
email to address (created by system) | |
obj['sobject']
|
text | email subject (created by system) |
obj['body']
|
richtext | mail body (created by system) |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
db.emailinbound.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.emailinbound.find(query, hints, function(err, res){
if (!err){
// res is an array of emailinbound instances
}
});
db.emailinbound.getById(ID, callback)
db.emailinbound.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a emailinbound instance
}
});
db.emailinbound.on(evt, callback)
db.emailinbound.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "emailinbound", data: "ID"}
// POST: {event: "post", collection: "emailinbound", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "emailinbound", data: ["ID1", "ID2", ...]}
}
});
go to top
var obj = new db.emailunsubscribed(properties);
var instance = new db.emailunsubscribed({"to": "value", ...});
name | type | description |
---|---|---|
obj['to']
|
unsubscribe email address (created by system) |
obj.save(callback)
obj.save(function(err, res){
if (!err){
// res is now the saved obj
}
});
obj.delete(callback)
obj.delete(function(err, res){
if (!err){
// res is the ID of the deleted object
}
});
obj.reload(callback)
obj.reload(function(err, res){
if (!err){
// res is now the reloaded object from the database
}
});
obj.on(evt, callback)
obj.on("PUT", function(err, evt){
if (!err){
// PUT: evt.data contain the ID of the updated object, i.e. obj
// DELETE: evt.data contain an array of IDs, of which one is this obj
}
});
db.emailunsubscribed.find(query, [hints], callback)
var query = {}; // get all records
var hints = {"$max": 10, "$orderby": {"_id": -1}}; // top ten, sort by creation id in descending order
db.emailunsubscribed.find(query, hints, function(err, res){
if (!err){
// res is an array of emailunsubscribed instances
}
});
db.emailunsubscribed.getById(ID, callback)
db.emailunsubscribed.getById("570e4661edb62e6a00000000", function(err, res){
if (!err){
// res is a emailunsubscribed instance
}
});
db.emailunsubscribed.on(evt, callback)
db.emailunsubscribed.on("POST", function(err, evt){
if (!err){
// evt contains data about event
// PUT: {event: "put", collection: "emailunsubscribed", data: "ID"}
// POST: {event: "post", collection: "emailunsubscribed", data: {_id: "ID", ...}}
// DELETE: {event: "delete", collection: "emailunsubscribed", data: ["ID1", "ID2", ...]}
}
});
go to top
db.on(event, callback)
db.on("PUT", function(error, eventdata){
// eventdata format: {event: "put", collection: "the-collection-name", data: "ID"}
}
db.on("POST", function(error, eventdata){
// eventdata format: {event: "post", collection: "the-collection.name", data: {_id: ID, ...}}
}
db.on("DELETE", function(error, eventdata){
// eventdata format: {event: "delete", collection: "the-collection-name", data: ["ID1", "ID2", ...]}
}
db.on("<your_event>", function(error, eventdata){
// eventdata format: {event: "<your_event>", data: {...}}
}
db.publish("<your_event>", {"answer": 42}, function(error, result){
// your handling code here
}