Overview
Classes
The CloudBoost API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and to use HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which can be understood by off-the-shelf HTTP clients, and we support cross-origin resource sharing to allow you to interact securely with our API from a client-side web application/mobile application (though you should remember that you should never expose your secret API master key in any public website's client-side code, Client Key can be exposed). JSON will be returned in all responses from the API, including errors (though if you're using API bindings/SDK, we will convert the response to the appropriate language-specific object).
https://cloudboost.io/js-sdk/cloudboost.js
https://cloudboost.io/js-sdk/cloudboost.min.js
npm install cloudboost
var CB = require('cloudboost');
https://github.com/CloudBoost/JavaScriptSDK
In Cloudboost, you create an app each of which has its own AppID, Client Key and the Master Key that you apply to your web app. Your master key is a secret which should not be shared in your client apps. Your account on CloudBoost can accommodate multiple apps. This is useful even if you have one application since you can deploy different versions for test and production.
appId, appKey )Initialize's the Application with CloudBoost
For each Application you create, there are two keys provided by CloudBoost,
void
CB.CloudApp.init('YOUR APP ID', 'YOUR APP KEY');
This class represents data in CloudBoost.
Each instance of CB.CloudObject represents
a row of table in Database. The data stored in CloudObject has schema which you can define in Table Designer
in CloudBoost portal. CloudBoost is schema-mix, so you can store or validate the piece of data with a schema.
It allows you to store data in key-value pairs, in database designed by you.
columnName, [objectId] )
Instantiates a CloudObject object.
It returns an instance of a CloudObject, as its a constructor.
Every instance of CloudObject has these properties
//creates an object for Student table
var obj = new CB.CloudObject("Student");
columnName, data )
Sets the value of an attribute of an instance of a CloudObject.
void
var obj = new CB.CloudObject('Student'); //create a new object.
obj.set("name", "John Smith"); //store string
obj.set("age", 21); // store number
obj.set("address", {
city: "Hyderabad",
state: "Telangana",
country: "India"
}); // store in object
columnName )
Gets the value of a column of an instance of CloudObject.
It returns the value of column which was previously set otherwise returns undefined if the column
is not set to a value.
var address = obj.get('address'); //get the data.
/* address will be
{
city: "Hyderabad",
state: "Telangana",
country: "India"
}
which was saved in the object using object.set
*/
columnName )
Removes the value of a column of an instance of a CloudObject to null.
void
var obj = new CB.CloudObject('Student');
obj.set("name", "John Smith");
obj.get("name"); //returns John Smith.
obj.unset("name");
obj.get("name"); //returns null.
[callback] )
Saves the instance of CloudObject to CloudBoost.
It returns a Promise which when resolved and returns instance of CloudObject saved
.If the promise is rejected, you get an error object back. (if callback is not provided).
var obj = new CB.CloudObject('Student');
obj.set("name", "Smith");
obj.save({
success: function(obj) {
//Saving successfull
//obj is instance of CloudObject
},
error: function(err) {
//Error occured in saving the object
}
});
[callback] )
Refreshes a CloudObject object by fetching its values from the database.
It returns Promise whcih resolves or rejects (if callback is not provided).
obj.fetch({
success: function(obj) {
//obj is an instance of a refreshed CloudObject
},
error: function(err) {
//Error occurred in fetching the data
}
});
[callback] )
Delete a CloudObject object, if it is saved in the database.
It returns Promise which resolves or rejects (if callback is not provided).
obj.delete({
success: function(obj) {
//success
},
error: function(err) {
//Error
}
});
tableName, eventType, functionToFire, [callback] )
Realtime Notifications : Listens to CloudObject events like insert, update, delete in the database.
created, updated, deleted are supported values.It returns a Promise (if callback is not provided).
//listen to an event
CB.CloudObject.on('Student', //name of the table
'created', //type of an event
function(obj){ //your custom function which you want to fire.
//obj is an instance of CloudObject
console.log('Student Created : '+obj.get('name'));
},{ //callback
success : function(){
//subscribe success
},
error : function(err){
//failed
}
});
tableName, eventType, [callback] )
Realtime Notifications : Switches off listening to CloudObject events like insert, update, delete
in the database.
created, updated, deleted are supported values.It returns a Promise (if callback is not provided).
//stop listening to an event
CB.CloudObject.off('Student', //name of the table
'created', //type of an event
{ //callback
success : function(){
//unsubscribe success
},
error : function(err){
//unsubscribe failed
}
});
Automatically deletes the object from the database at specified time. Sets the expiration time for CloudObject.
Expiration time is to be given as number of milliseconds from 1 Jan 1970.
var obj = new CB.CloudObject('Student');
obj.set('name', 'John Smith');
expire=new Date().getTime()+1000; //increase the expiration time by 1 second from current time
obj.expires = expires; //Set the expire time for object Student
columnName,tableName,objectId)
Relates a CloudObject which is already saved to this CloudObject. Can be used to
relate objects together in a relation.
CloudObject.
CloudObject which you want to relate to.
void
var obj = new CB.CloudObject('Student');
obj.relate('teacher','Teacher','xxxxxx'); //relates the teacher in the Teacher table with id xxxxx to this student.
ObjectArray, [callback])
Saves an Array of CloudObject.
Array of Saved CloudObjects
var obj1 = new CB.CloudObject('Student');
obj1.set('name','abcd');
var obj2 = new CB.CloudObject('Student');
obj2.age('age',10);
CB.CloudObject.saveAll([obj1,obj2]).then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
ObjectArray, [callback])
Deletes an Array of CloudObject.
Array of Deleted CloudObjects
CB.CloudObject.deleteAll([obj1,obj2]).then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
cloudObjects, [callback] )
Stores the CloudObjects to the local store
Array of Stored CloudObjects
CB.CloudObject.pin([obj1,obj2]).then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
cloudObjects, [callback] )
Removes the CloudObjects from local store
Array of CloudObjects which are removed
CB.CloudObject.unPin([obj1,obj2]).then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
[callback] )
Helps pin and save the CloudObject in local storage.
It returns a Promise which when resolved and returns instance of CloudObject saved .If the promise
is rejected, you get an error object back. (if callback is not provided).
CB.CloudObject.saveEventually().then(function(res){
console.log(res);
},function(err){
console.log(err);
});
[callback] )
Removes all the CloudObjects from the local store
Array of CloudObjects which are removed
CB.CloudObject.clearLocalStore().then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
[callback] )
To fetch all CloudObjects from Local Storage
Array of CloudObjects which are stored in Local Storage
CB.CloudObject.sync().then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
[callback] )
To diable sync of CloudObjects from Local Storage
Array of CloudObjects which are stored in Local Storage
CB.CloudObject.disableSync().then(function(res){
console.log(res);
},function(err){
console.log(err);
}
);
This section is dedicated to modelling relationships with CloudBoost.
There are usually three types of relationships.
If you want to model one-to-one relationship. Then you need to create a new column of type Relation pointed to a table which you want it to be related to and set that column Unique property
to true.
var student = new CB.CloudObject("Student");
var address = new CB.CloudObject("Address");
//here one student can only have one address for example.
//address column of Student Table is pointed to the Address Table with unique set to true.
student.set('address', address);
student.save({
success : function(student){
//saved
}, error : function(err){
//error
}
});
If you want to model one-to-many relationship. Then you need to create a new column of type Relation pointed to a table which you want it to be related to and set that column Unique property
to false.
var teacher = new CB.CloudObject("Teacher");
var course = new CB.CloudObject("Course");
//here one teacher can be assigned to many courses.
course.set('teacher', teacher);
course.save({
success : function(course){
//saved course with teacher.
}, error : function(err){
//error
}
});
If you want to model many-to-many relationship. Then you have two options
This option is recommended only if you have huge number of relationships assigned to any one object.
This relationship can be created by creating a third table and having two columns that are relatied to tables you want to have many to many relationships on.
This option is recommended only if you have small number of relationships assigned to any one object.
This relationship can be created by creating an array and having related objects pushed to that array and having that array saved in any column of the table.
//Type #1 : Relation Option
var student = new CB.CloudObject("Student");
var course = new CB.CloudObject("Course");
//here one student be into many courses, and vice versa.
var studentCourse = new CB.CloudObject('StudentCourse');
studentCourse.set('student', student);
studentCourse.set('course', course);
studentCourse.save({
success : function(studentCourse){
//saved studentCourse with two related objects.
}, error : function(err){
//error
}
});
//Type #2 : List Option.
var student = new CB.CloudObject("Student");
//create an array.
var courseList = [];
//a new course
var course = new CB.CloudObject("Course");
//add it to the list. You can push any number of objects you need.
courseList.push(course);
//here one student be into many courses, and vice versa.
student.set('courses', courseList);
//save
student.save({
success : function(student){
//saved student with two related objects.
}, error : function(err){
//error
}
});
Relations are of two types and if you want to query relationships then there is a different type of query for each of the
type. Two types are :
To query on a Relation, You can use CloudQuery function EqualTo / NotEqualTo
To query on a List of Relations , You can use CloudQuery function ContainedIn / NotContainedIn
/ ContainsAll
//Type #1 : Relation Option.
//Get all the course which belong to a teacher
var courseQuery = new CB.CloudQuery('Course');
courseQuery.equalTo('teaher', teacher); //teacher is an instance of CloudObject and should have an Id.
courseQuery.find({
success : function(list){
//list of CloudObject
}, error : function(error){
//error
}
});
//Type #2 : Query on List of Relations.
//Get all the courses which the student belongs to.
//Assume : Course has a list of Students, in the column 'students'
var courseQuery = new CB.CloudQuery('Course');
courseQuery.containsIn('student', student); //student is an instance of CloudObject and should have an Id.
courseQuery.find({
success : function(list){
//list of CloudObjects
}, error : function(error){
//error
}
});
It encapsulates a set of methods and attributes required to query your data in CloudApp to
retrieve desired set of results.
Instantiates a CloudQuery object.
void
var query = new CB.CloudQuery("Student");
columnName )
Return's true if the result matches with all of the values of given columnName, similar to
keyword any in SQL Query's.
Primarily, used to run nested queries.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.all('course');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )
Return's true if the result matches with any one values of given columnName, similar to keyword
any in SQL Query's.
Primarily, used to run nested queries.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.any('first_name');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )
Return's true if the result matches with very first value of given columnName.
Primarily, used to run nested queries.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.first('teacher');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
search, language, caseSensitive, diacriticSensitive )It allows you to search on basis of criteria provided by you.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.search('my_string');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constriant for finding the subset of the data in which
columnName is equal to data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.equalTo('age', 21); //find all Students who age is 21
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constriant for finding the subset of the data in which
columnName does not has the value data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
//find all Students info except of Smith
query.notEqualTo('name', 'Smith');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
callback )It deletes all the data from Table
void
var query = new CB.CloudQuery("Student");
query.delete();
columnName, data )
If you want to retrieve objects matching several different values, you can use containedIn,
providing an array of acceptable values. This is often useful to replace multiple queries with a single
query.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
//Get Student where name is equal to Smith, Max OR Lucy
query.containedIn('name', ['Smith', 'Max', 'Lucy']);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
Find objects where the array data in columnName contains all of the elements of data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
//find Students who are in JavaScript AND C# class
query.containsAll('classes', ['JavaScript', 'C#']);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
If you want to retrieve objects which doesn't include certain values, you can use notContainedIn,
providing an array of acceptable values. This is often useful to replace multiple queries with a single
query.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
//Get all Students except Smith, Max and Lucy
query.notContainedIn('name', ['Smith', 'Max', 'Lucy']);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constraint for finding the subset of the data in which
columnName has the value greater than data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Teacher");
//find all the teachers who are old.
query.greaterThan('age', 60);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constraint for finding the subset of the data in which
columnName has the value greater than or equals to data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Teacher");
query.greaterThanEqualTo('age', 60);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constraint for finding the subset of the data in which
columnName has the value less than data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.lessThan('age', 18);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constraint for finding the subset of the data in which
columnName has the value less than or equals to data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.lessThanEqualTo('age', 17);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, data )
It adds a constraint to find the data in which value of columnName of each data is starts
with
data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
//find all the Students who name starts with letter 'S'
query.startsWith('name', 'S');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
query1, query2 )
It adds a logical OR constraint between 2 CloudQuery objects for finding the set of the data
satisfying conditions of both query1 and query2.
Both of the CloudQuery objects should be of the same collection otherwise it throws an error.
CloudQuery objectCloudQuery objectIt returns a CloudQuery object which contains OR'ed query of both of the CloudQuery objects.
//find all Student such that 10<age<18
var query1 = new CB.CloudQuery('Student');
query1.lessThan('age', 18);
var query2 = new CB.CloudQuery('Student');
query2.greaterThan('age', 10);
var query = CB.CloudQuery.or(query1, query2);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )It adds a constraint for arranging the subset of the data in ascending order.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.orderByAsc('age');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )It adds a constraint for arranging the subset of the data in descending order.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.orderByDesc('age');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
data )It adds a constraint to limit no. of the data to be fetched from the database.
If it is not set explicitly, database returns 20 results by default.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.setLimit(5);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
data )
It adds a constraint to skip data no. of data matching satisfying the query constraints and
fetching from the database.
It requires a sort constraint and if none of it is provided by the user then the documents are sorted according to the createdAt attribute associated with the data.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.setSkip(5);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
pageNo, totalItemsInPage, [callback])Paginate returns only the specified number of objects from the database. It takes in the current page number and total items in page as parameters and returns list of objects,count,total number of pages.
List of objects,count,total number of pages
var query = new CB.CloudQuery("Student");
query.paginate( 2, 10, {
success: function(objectsList, count, totalPages){
//objectsList is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnNames )It adds a constraint limiting the columns that are to fetched for each of the data from the database.
id, createdAt, updatedAt and ACL are always returned unless explicitly provided by the user to discard it using doNotSelectColumn()
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.selectColumn(['name', 'age']);
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnNames )
It adds a constraint restricting the columns given in columnNames to be fetched for each of
the data from the database.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.greaterThan('age', 18);
query.doNotSelectColumn('address');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )
It adds a constraint for finding the subset of the data in which
columnName exists irrespective of what its value is.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.exists('address');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )
It adds a constraint for finding the subset of the data in which
columnName does not exists.
Same query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery("Student");
query.doesNotExists('address');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
[callback] )
Queries the database on the constraints provided by the CloudQuery object and gets the result
as an array of CloudObject objects.
If no. of documents to be returned is not specified using limit() then at max 20 documents are returned in each query by default.
If no. of documents to be skipped is specified using skip() without sorting
parameter then the documents matching the query provided in
CloudQuery object are sorted in ascending order of createdAt field.
It returns an array of CloudObject objects or an error object if the opertion is successful
or fails respectively along with JQuery promise (if callback is not provided).
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
[callback] )
Queries the database on the constraints provided by the CloudQuery object and gets a single
CloudObject object satisfying the constraint.
If no. of documents to be skipped is specified using skip() without sorting
parameter then the documents matching the query provided in
CloudQuery object are sorted in ascending order of createdAt field.
It returns a CloudObject object or an error object if the opertion is successful or fails
respectively along with JQuery promise (if callback is not provided). It throws an error
too if sufficient data is not available to query the database
query.findOne({
success: function(obj){
//obj is an instance of CloudObject
},
error: function(err) {
//Error in retrieving the data.
}
});
[callback] )
Queries the database on the constraints provided by the CloudQuery object and gets a single
CloudObject object satisfying the constraint.
If no. of documents to be skipped is specified using skip() without sorting
parameter then the documents matching the query provided in
CloudQuery object are sorted in ascending order of createdAt field.
It returns a CloudObject object or an error object if the opertion is successful or fails
respectively along with JQuery promise (if callback is not provided). It throws an error
too if sufficient data is not available to query the database
query.findFromLocalStore({
success: function(obj){
//obj is an instance of CloudObject
},
error: function(err) {
//Error in retrieving the data.
}
});
[callback] )
Queries the database on the constraints provided by the CloudQuery object and gets a single
CloudObject object satisfying the constraint.
If no. of documents to be skipped is specified using skip() without sorting
parameter then the documents matching the query provided in
CloudQuery object are sorted in ascending order of createdAt field.
It returns a CloudObject object or an error object if the opertion is successful or fails
respectively along with JQuery promise (if callback is not provided). It throws an error
too if sufficient data is not available to query the database
query.findById({
success: function(obj){
//obj is an instance of CloudObject
},
error: function(err) {
//Error in retrieving the data.
}
});
id, [callback] )
Queries the database gets a CloudObject object whose id field matches id.
It returns a CloudObject object or an error object if the opertion is successful or fails
respectively along with JQuery promise (if callback is not provided). It throws an error
too if sufficient data is not available to query the database
query.get('xxxxx', {
success: function(obj){
//obj an instance of CloudObject
},
error: function(err) {
//Error in retrieving the data.
}
});
[callback] )
It adds a constraint to find the data in which value of columnName of each data is at least
equal to all of the value(s) provided in data.
It returns an Integer which is the number of documents matching the constraints given in the CloudQuery object along with JQuery promise (if callback is not provided).
query.count({
success: function(count){
//count is the count of data which belongs to the query
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName, [callback] )
It returns distinct objects which have columnName
Sort parameter is required and if not provided by the user then ascending order sorting on createdAt field is applied by default.
It returns an array of CloudObject objects which are documents matching the given query in
the CloudQuery object having distinct values of
ColumnName along with JQuery promise (if callback is not provided).
query.distinct('address', {
success: function(data){
//data is an array of document(s)
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName )
It gives the join on columnName for the table being queried upon.
Same query object, which can be helpful in chaining query functions.
//joins table student with hostel
var query = new CB.CloudQuery("Student");
query.include('hostel');
query.find({
success: function(list){
//list is an array of CloudObjects
},
error: function(err) {
//Error in retrieving the data.
}
});
columnName ,geoPoint, range )
Queries for CloudObject objects which are within range.It gives result in the order of nearest
to farthest.
CloudGeoPointSame query object, which can be helpful in chaining query functions.
var loc = new CB.CloudGeoPoint(17.7,80.3);
var query = new CB.CloudQuery('Custom5');
query.near("location", loc, 100000);
query.find().then(function(list) {
//searches for cloudobjects within 100000 meters
}, function (err) {
//error
})
});
ColumnName, CloudGeoPoint, Radius )Queries for CloudObject objects which are within range.
CloudGeoPointSame query object, which can be helpful in chaining query functions.
var loc1 = new CB.CloudGeoPoint(18.4,78.9);
var loc2 = new CB.CloudGeoPoint(17.4,78.4);
var loc3 = new CB.CloudGeoPoint(17.7,80.4);
var query = new CB.CloudQuery('Custom');
query.geoWithin("location", [loc1, loc2, loc3]);
query.find().then(function(list) {
//searches for cloudobjects within triangle formed by the CloudGeoPoints
}, function (err) {
//error
})
});
columnName, value, isCaseInsensitive )Queries for CloudObject objects which matches given regular expression.
CloudGeoPointSame query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery('Student');
query.regex(username, "/a", true);
query.find().then(function(list) {
//searches for cloudobjects within triangle formed by the CloudGeoPoints
}, function (err) {
//error
})
});
columnName, value, isCaseInsensitive )Queries for CloudObject objects whose column values contains the given substring.
CloudGeoPointSame query object, which can be helpful in chaining query functions.
var query = new CB.CloudQuery('Student');
query.substring(username, "as a", false);
query.find().then(function(list) {
//searches for cloudobjects within triangle formed by the CloudGeoPoints
}, function (err) {
//error
})
});
In Cloudboost, you can create realtime notification channels, publish messages to those channels and have other clients listen to those messages which are being published in real time.
channelName, functionToFire, [callback] )Listens to notification channels.
success
and error functions to handle respective response.It returns JQuery promise, if callback is not specified
CB.CloudNotification.on('Sample',function(data){
console.log(data);
});
channelName, data, [callback] )Publishes data to notification channels.
success
and error functions to handle respective response.It returns JQuery promise, if callback is not specified
CB.CloudNotification.publish('sample','data');
channelName, [callback] )Stops listening to notification channel.
success
and error functions to handle respective response.It returns JQuery promise, if callback is not specified
CB.CloudNotification.off('sample');
In Cloudboost, you can send push notifications. Push notifications are a very important feature in an app because it enables seamless communication from your server to your app.
dataJSON, cloudQuery/ChannelArray/SingleChannelString, [callback] )Sending push notifications
message
property, and title ,icon are optional. icon is only aplicable for android and IOS.success
and error functions to handle respective response.
It returns JQuery promise, if callback is not specified
var query = new CB.CloudQuery("Device");
query.containedIn('channels', "hackers");
CB.CloudPush.send({message:"my first notifications"},query,{
success:function(){
//Success
},
error:function(error){
//Error
}
});
[callback] )When fired turns on the Web Notificaitons for your Application.
success
and error functions to handle respective response.
It returns JQuery promise, if callback is not specified
var query = new CB.CloudQuery("Device");
query.containedIn('channels', "hackers");
CB.CloudPush.enableWebNotifications({
success:function(){
//Success
},
error:function(error){
//Error
}
});
[callback] )When fired turns off the Web Notificaitons for your Application.
success
and error functions to handle respective response.
It returns JQuery promise, if callback is not specified
var query = new CB.CloudQuery("Device");
query.containedIn('channels', "hackers");
CB.CloudPush.disableWebNotifications({
success:function(){
//Success
},
error:function(error){
//Error
}
});
deviceOS, endPoint, browserKey, authKey, [callback] )Adds a device for Push Notificaitons
success
and error functions to handle respective response.
success
and error functions to handle respective response.
success
and error functions to handle respective response.
It returns JQuery promise, if callback is not specified
CB.CloudPush._addDevice("android", "xxxx", "deviceToken", "xyxy", "auth_key",{
success:function(){
//Success
},
error:function(error){
//Error
}
});
deviceOS, endPoint, [callback] )Deletes a device being registered for Push Notificaitons
success
and error functions to handle respective response.
It returns JQuery promise, if callback is not specified
var query = new CB.CloudQuery("Device");
query.containedIn('channels', "hackers");
CB.CloudPush._deleteDevice("Android","xxxx",{
success:function(){
//Success
},
error:function(error){
//Error
}
});
CloudGeoPoint is used to store GeoPoints and perform GeoPoint operation like finding points
near and bounding box.
A CloudGeoPoint object has to be saved in CloudObject in a column.
All the modifications in the GeoPoint can be reflected only after the object is saved after the changes.
Init's a CloudGeoPoint object.
It takes latitude and longitude of a GeoPoint. Points can be given in Numeric format.
It returns a CloudGeoPoint object.
var point = new CB.CloudGeoPoint(17.4,78.5);
Finds distance between CloudGeoPoints in kilometers.
Distance in Kilometers.
var loc = new CB.CloudGeoPoint(17.7,80.3);
var loc2 = new CB.CloudGeoPoint(10.7,70.3);
var distance = loc.distanceInKMs(loc2);
Finds distance between CloudGeoPoints in Miles.
Distance in Miles.
var loc = new CB.CloudGeoPoint(17.7,80.3);
var loc2 = new CB.CloudGeoPoint(10.7,70.3);
var distance = loc.distanceInMiles(loc2);
Finds distance between CloudGeoPoints in kilometers.
Distance in Radians.
var loc = new CB.CloudGeoPoint(17.7,80.3);
var loc2 = new CB.CloudGeoPoint(10.7,70.3);
var distance = loc.distanceInRadians(loc2);
There is a notion of user accounts that lets users access their information in a secure manner. We provide a specialized
user class called CB.CloudUser that automatically handles much of the functionality
required for user account management.
CB.CloudUser is a subclass of CB.CloudObject, and has all the same features,
such as flexible schema, automatic persistence, and a key value interface. All the methods that are on
CB.CloudObject also exist in CB.CloudUser. The difference is that CB.CloudUser has some special additions specific to user accounts. With this class, you'll be able to add user account
functionality in your app.
There is a special object CB.CloudUser.current which holds the information of the current
user logged in.
Instantiates a CloudUser object.
It takes no argument.
var obj = new CB.CloudUser();
[callback] )It registers new user given its username, email and password. Registration is successful if the given email is not already registered to an existing user.
It sets the attributes of CB.CloudUser.current object with the
CloudUser object recieved.
It returns a CloudUser object which has the user information if registration is successful
otherwise an error object along with JQuery promise (if callback is not provided).
var user = new CB.CloudUser();
user.set('username', 'my_username');
user.set('password', 'my_solid_password');
user.set('email', 'email@sample.com');
user.signUp({
success: function(user) {
//Registration successfull
},
error: function(err) {
//Error in user registration.
}
});
[callback] )It logs in user given its username and password. Login is successful if the given username and password pair is already present in the database.
It sets the attributes of CB.CloudUser.current object with the
CloudUser object recieved.
It returns a CloudUser object which has the user information if registration is successful
otherwise an error object along with JQuery promise (if callback is not provided).
var user = new CB.CloudUser();
user.set('username', 'my_username');
user.set('password', 'my_solid_password');
user.logIn({
success: function(user) {
//Login successfull
},
error: function(err) {
//Error occured in user registration.
}
});
[callback] )It logs the user out.
It sets the CB.CloudUser.current object to null.
It returns a CloudUser object having the user information of the user who was logged in
otherwise an error object along with JQuery promise (if callback is not provided).
CB.CloudUser.current.logOut({
success: function(user) {
//log out successfull
},
error: function(err) {
//Error occured in user registration.
}
});
[callback] )
It gives the current value for CB.CloudUser.current object.
It returns a CloudUser object having the user information of the user who was logged in
otherwise an error object along with JQuery promise (if callback is not provided).
CB.CloudUser.getCurrentUser({
success: function(user) {
//success
},
error: function(err) {
//error
}
});
It gets the current user from the cookie or from local storage.
It returns a CloudUser object having the user information of the user who was logged in
otherwise null.
//returns current user from local storage
var current_user = CB.CloudUser._getCurrentUser();
[callback] )Get the current logged in user.
//gets the current user if user is loggedIn, null otherwise.
var currentUser = CB.CloudUser.current;
It sets the value of current user to the user who is currently logged in.
void
var user = CB.CloudUser();
user.set('username', 'my_username');
user.set('password', 'my_solid_password');
user.set('email', 'email@sample.com');
CB.CloudUser._setCurrentUser(user);
It sets the value of current user to null.
void
//removes the current user
CB.CloudUser._removeCurrentUser(user);
dataJson, [callback] )Used for authenticating the user with providers such as Twitter, Facebook and Google.
It returns a JQuery promise (if callback is not provided).
var dataJson = {provider : "twitter", accessToken : "zzzz" , accessSecret : "xxxx"};
//for others accessSecret is not required
CB.CloudUser.authenticateWithProvider(dataJson, {
success: function(user) {
//Success
},
error: function(err) {
//Error
}
});
role, [callback] )A user can be a part of many roles, like in real world. For this functionality user should get added to a Role.
For this purpose addToRole() of CB.CloudUser comes in handy.
CloudRole object of the role you want to
add the user to.
It returns a CloudUser object having the user information of the user who was logged in
otherwise an error object along with JQuery promise (if callback is not provided).
//role is an instance of CloudRole Object.
CB.CloudUser.current.addToRole(role, {
success: function(user) {
//added to role successfull
},
error: function(err) {
//Error occured in adding to role.
}
});
Given getRole() is discussed later
role )To check if the current user is in the role provided by the role object.
CloudRole object of the role you want to
check the user to.It returns a true/false based on whether the user is in the given role or not respectively.
//role is the instance of the CloudRole object.
if(CB.CloudUser.current.isInRole(role)) {
//The current user is in the given role.
} else {
//The user is not in the given role.
}
}
Given getRole() is discussed later
role , [callback] )
Removes the user from the given role provided in role object.
CloudRole object of the role you want to
remove the user from.
It returns a CloudUser object having the user information of the user who was logged in
otherwise an error object along with JQuery promise (if callback is not provided).
CB.CloudUser.current.removeFromRole(role, {
success : function(user){
//get the updated user
},
error : function(err){
//erorr if something goes wrong.
}
});
}
Given getRole() is discussed later
oldPassword, newPassword, [callback] )Used to change the password for current user.
It returns a JQuery promise (if callback is not provided).
CB.CloudUser.current.changePassword("my_solid_password", "my_rock_solid_password", {
success : function(user){
//get the updated user
},
error : function(err){
//erorr if something goes wrong.
}
});
}
email, [callback] )Used to reset the password for current user.
It returns a JQuery promise (if callback is not provided).
CB.CloudUser.current.resetPassword("email@random.com", {
success : function(user){
//get the updated user
},
error : function(err){
//erorr if something goes wrong.
}
});
}
As your app grows in scope and user-base, you may find yourself needing more coarse-grained control over access to pieces of your data than user-linked ACLs can provide. To address this requirement, CloudBoost supports a form of Role-based Access Control. Roles provide a logical way of grouping users with common access privileges to your CB data. Roles are named objects that contain users and other roles. Any permission granted to a role is implicitly granted to its users as well as to the users of any roles that it contains.
We provide a specialized class called CB.CloudRole that represents these role objects in your
client code. CB.CloudRole is a subclass of CB.CloudObject, and has all of the
same features, such as a flexible schema, automatic persistence, and a key value interface. All the methods
that are on CB.CloudObject also exist on CB.CloudRole. The difference is that
CB.CloudRole has some additions specific to management of roles.
Instantiates a CloudRole object.
var role = new CB.CloudRole("Student");
Instantiates a CloudFile object.
var documentFile = new Blob(['This is the content of by document blob'],
{type : 'text/plain'});
var file = new CB.CloudFile(documentFile);
[callback] )
Saves the CloudFile object.
CloudFile object having url attribute set to the URL of the blob
uploaded to the server if the operation is successful otherwise returns an error object along with JQuery
promise (if callback is not provided).
var documentFile = new Blob([
'This is the content of by document blob'
], {
type : 'text/plain'
});
var file = new CB.CloudFile(documentFile);
file.save({
success: function(roleObj) {
//got the file object successfully with the url to the file
},
error: function(err) {
//error in uploading file
}
});
[callback] )
Saves the CloudFile object.
CloudFile object having url attribute set to null if
the operation is successful otherwise returns an error object along with JQuery promise (if callback is not provided).
file.delete({
success: function(fileObj) {
//file deletion successful
},
error: function(err) {
//error in deleting file
}
});
[callback] )
Fetches the CloudFile object which has the URL along with other Properties of File.
CloudFile object having url if the operation is successful otherwise
returns an error object along with JQuery promise (if callback is not provided).
var query = new CB.CloudQuery("Custom");
query.find().then(function(res)
var file = res.get('file');
file.fetch({
success: function(roleObj) {
//Gets File Object
},
error: function(err) {
//error in geting file
}
},function(){
//error querying object
});
});
[callback] )
Get's the CloudFile content.
CloudFile object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var query = new CB.CloudQuery("Custom");
query.find().then(function(res)
var file = res.get('file');
file.fetch({
success: function(fileObj) {
fileObj.getFileContent({
success: function(fileObj) {
//Gets the Content of the File Pointed By File Object
},
error: function(err) {
//error in getting File Content
});
//Gets File Object
},
error: function(err) {
//error in getting file
})
},function(){
//error querying object
});
});
Instantiates a CloudCache object.
var cache = new CB.CloudCache("myCache");
key, value, [callback] )
Sets the CloudCache with data.
CloudCache object having cache information if callback is defined
on success, otherwise returns an error object along with JQuery promise (if callback is not
provided).
var data = "some_useful_info";
var cache = new CB.CloudCache("myCache");
cache.set("key1",data,{
success: function(cacheObj){
//success
},
error: function(err){
//error
}
});
key, [callback] )Deletes the data related to the key provided as parameter.
CloudCache object having cache information on success, or JQuery
Promise on error.
var cache = new CB.CloudCache("myCache");
cache.deleteItem("key1",{
success: function(cacheObj){
//success
},
error: function(err){
//error
}
});
[callback] )Creates a URL for your cache
CloudCache object having url if the operation is successful otherwise
returns an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
cache.create({
success: function(cacheObj){
//success
},
error: function(err){
//error
}
});
key, [callback] )
Get's the information from CloudCache related to the particular key.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
//set the data here
var data = cache.get("key1", {
success: function(cacheObj){
//success
},
error: function(err){
//error
});
[callback] )
Get's the whole cache from CloudCache.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
var data = cache.getInfo({
success: function(cacheObj){
//success
},
error: function(err){
//error
});
[callback] )
Get's the count of items being present in CloudCache.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
var count = cache.getItemsCount({
success: function(cacheObj){
//success
},
error: function(err){
//error
});
[callback] )
Get's the whole cache from CloudCache.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
var data = cache.getInfo({
success: function(cacheObj){
//success
},
error: function(err){
//error
});
[callback] )
Clears the cache content from CloudCache.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
var returnObj = cache.clear();
[callback] )
Deletes the whole cache from CloudCache.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var cache = new CB.CloudCache("myCache");
cache.delete({
success: function(cacheObj){
//success
},
error: function(err){
//error
});
[callback] )
Deletes all cache present from CloudCache.
CloudCache object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
CB.CloudCache.deleteAll({
success: function(cacheObj){
//success
},
error: function(err){
//error
});
FIFO(First In First Out) manner. The most common use
case is for triggering events in the order that they are pushed into the CloudQueue.
Instantiates a CloudQueue object.
var queueName = "myQueue";
var queueType = "push";
var queue = new CB.CloudQueue(queueName,queueType);
queueMessage, [callback] )
Adds a message to the CloudQueue object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
var queue = new CB.CloudQueue("myQueue","push");
queue.addMessage("Message String",{
success: function(messages){
//success
},
error: function(err){
//error
}
});
queueMessage, [callback] )
Updates the message in CloudQueue object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
queue.updateMessage("New Message String",{
success: function(messages){
//success
},
error: function(err){
//error
}
});
[count], [callback] )
Gets the message from CloudQueue object.
Gets the first message if count is not defined, else returns the number of messages according to count.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.getMessage(3,{
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )
Get's all the message from CloudQueue.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//creat a queue
queue.getAllMessages({
success: function(messages){
//success
},
error: function(err){
//error
}
});
id, [callback] )
Get's the message from CloudQueue according to its id.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//creat a queue
queue.getMessageById("message_id",{
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )
Helps fetch the CloudQueue object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//creat a queue
queue.get({
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )
Creates a URL for the CloudQueue queue according to its name.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.create({
success: function(messages){
//success
},
error: function(err){
//error
}
});
url, [callback] )
Adds subscribers to CloudQueue Object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.addSubscriber(url, {
success: function(messages){
//success
},
error: function(err){
//error
}
});
url, [callback] )
Remove's the subscriber from CloudQueue Object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.removeSubscriber(url, {
success: function(messages){
//success
},
error: function(err){
//error
}
});
count, [callback] )
Remove's the subscriber from CloudQueue Object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.peekMessage(3, {
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )Deletes the queue from server.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.delete({
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )Clears the Queue content
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.clear({
success: function(messages){
//success
},
error: function(err){
//error
}
});
id, timeout, [callback] )Helps you set timeout to refresh the queue at regular intervals.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.refreshMessageTimeout(id, timeout, {
success: function(messages){
//success
},
error: function(err){
//error
}
});
id, [callback] )Deletes the message corresponding to the id provided.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.deleteMessage("xxxx", {
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )Updates the queue on the server.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.update({
success: function(messages){
//success
},
error: function(err){
//error
}
});
[callback] )Gets all the queues with their respective messages from the server.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.getAll({
success: function(messages){
//success
},
error: function(err){
//error
}
});
queueName, [callback] )Get details of the Queue corresponding to given QueueName.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.get("myQueue", {
success: function(messages){
//success
},
error: function(err){
//error
}
});
queueName, [callback] )Deletes the queue from the server.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.delete("myQueue", {
success: function(messages){
//success
},
error: function(err){
//error
}
});
data )Helps you create a Queue Message Object.
CloudQueue object if the operation is successful otherwise returns
an error object along with JQuery promise (if callback is not provided).
//create a queue
queue.QueueMessage("message_data");
This API allow to create a column object.
columnName, dataType, [required], [unique])
Initialize a column.
List of valid Data Type is given below.
Reqiure is a boolean that indicate whether the field can be null or not.
Unique field is a boolean type, indicates whether should contains unique value or not.
A cloudcolumn object
var column1 = new CB.Column('name', 'Text', true, false);
var column2 = new CB.Column('uniqueId');
column2.dataType = 'Number';
column2.unique = true;
column2.required = true;
var table = new CB.CloudTable('Employee');
table.addColumn(column1);
table.addColumn(column2);
table.save().then(function(obj){
//cloud table object
}, function(err){
//error
});
List of Valid Data Types
data types are case sensitive
If you are using Relation as a data type then you need to set relatedTo property to column
object
.
Valid relatedTo data types for Relation is CloudTable Object i.e. just set the table
name in relatedTo property.
If you are using List as a data type then you need to set relatedTo property to column
object
.
Valid relatedTo data types for List are:
['CloudTable Objects', 'Text', 'Email', 'URL', 'Number', 'Boolean', 'DateTime', 'Boolean', 'GeoPoint',
'File', 'Object']
var column3 = new CB.Column('department', 'Relation');
column3.relatedTo = 'DepartmentTable';
var column4 = new CB.Column('skills', 'List');
column4.relatedTo = 'Text';
var table = new CB.CloudTable('Employee');
table.addColumn(column3);
table.addColumn(column4);
table.save().then(function(obj){
//cloud table object
}, function(err){
//error
});
Used to set a column as required.
var column3 = new CB.Column('department',);
column3.required = true;
Used to set a column as unique.
var column3 = new CB.Column('department',);
column3.unique = true;
This API allows to create, delete, get details of a table from an App by using master-key.
tableName)All the tables are in CloudBoost is a type of CloudTable. Pass the table name as a parameter to initialize a CloudTable.
A CloudTable object
var table = new CB.CloudTable("TableName");
CloudTable, [callback])To get a table's detail of an App use get method.
A CloudTable Object
var obj = new CB.CloudTable('Address');
CB.CloudTable.get(obj).then(function(table){
//Get CloudTable Object for requested table.
}, function(err){
//get error details
});
[callback])It fetch all tables of an App.
Array of CloudTable object
CB.CloudTable.getAll().then(function(tableArray){
//get array of CloudTables
}, function(err){
//get error details
});
columnObj)Add a column to a table. go through Column to get more detail about how to initialize a column object.
Void
var table = new CB.CloudTable('Student');
var column = new CB.Column('Name', 'Text');
table.addColumn(column);
table.save().then(function(obj){
//new table object with new column
}, function(err){
});
columnObj)Delete a column of a Table. go through Column to get more detail about how to initialize a Column Object.
Void
var column = new CB.Column('Name', 'Text');
table.deleteColumn(column);
table.save().then(function(obj){
//updated table object without 'Name' column
}, function(err){
});
[callback])Save a CloudTable Object. It will automatically create all default columns for a table. If you want to create a user table or role table then just pass 'User' or 'Role' as an argument while creating cloudtable object.
CloudTable Object
var table = new CB.CloudTable('NewTable');
table.save().then(function(obj){
//saved cloudtable object
}, function(err){
});
[callback])Delete a CloudTable object i.e. delete a table of an App.
Success or Error Status
var table = new CB.CloudTable('Student');
table.delete().then(function(status){
//success status
},function(){
//get error status
});
column)Get's the column object.
Cloud Column Object
var table = new CB.CloudTable('Student');
var acl = table.getColumn('ACL');
//gets the ACL column
Column)Updated the CloudTable column to the column passed in.
void
var table = new CB.CloudTable('Student');
var name = new CB.Column('name');
name.unique = true;
table.updateColumn(name);
//updated the existing column name to new Column
Each CloudObject namespace has security option by default. By default every object
can be read and modified by anyone so for each object change the security option as desidred. For
any object, you can specify which users/roles are allowed to read the object, and which users/roles
are allowed to modify an object. To support this type of security, each object has an access control
list, implemented by the CB.ACL class.
For each object CB.ACL object is a property in CloudObject.ACL class.
All the modifications in the ACL can be reflected only after the object is saved after the changes.
Instantiates an ACL object.
It takes no argument
It returns nothing. It is called using a variable of which various parameters are set.
var obj = new CB.CloudObject('Student');
obj.ACL = new CB.ACL();
value )To allow/disallow public to write on a particular CloudObject
void
var obj = new CB.CloudObject("Student");
obj.ACL = new CB.ACL();
obj.ACL.setPublicWriteAccess(false);
obj.save({
success: function(obj) {
//Saving successfull
},
error: function(err) {
//Error occured in saving the object
}
});
value )To allow/disallow public to read a particular object
void
var obj = new CB.CloudObject("Student");
obj.ACL = new CB.ACL();
obj.ACL.setPublicReadAccess(false);
obj.save({
success: function(obj) {
//Saving successfull
},
error: function(err) {
//Error occured in saving the object
}
});
userId, value )To allow/disallow user having to write on a particular object.
void
var obj = new CB.CloudObject("Student");
obj.ACL = new CB.ACL();
obj.ACL.setUserWriteAccess('idOfTheUser',true);
obj.save({
success: function(obj) {
//Saving successfull
},
error: function(err) {
//Error occured in saving the object
}
});
userId, value )
To allow/disallow user having _id userId to read a particular object.
It returns nothing.
var obj = new CB.CloudObject("Student");
obj.ACL = new CB.ACL();
obj.ACL.setUserReadAccess('idOfTheUser',true);
obj.save({
success: function(obj) {
//Saving successfull
},
error: function(err) {
//Error occured in saving the object
}
});
roleId, value )
To allow/disallow users of roles roleId to write on a particular object
void
var obj = new CB.CloudObject("Student");
obj.ACL.setRoleWriteAccess('roleId', true);
obj.save({
success: function(obj) {
//Saving successfull
},
error: function(err) {
//Error occured in saving the object
}
});
roleId, value )
To allow/disallow users of roles roleId to read a particular object
void
var obj = new CB.CloudObject("Student");
obj.ACL.setWriteAccess('roleId', true);
obj.save({
success: function(obj) {
//Saving successfull
},
error: function(err) {
//Error occured in saving the object
}
});
Here's a way to serialize and de-serialize CloudBoost objects for passing it between your server and clients.
data )Convert CloudBoost Object to JSON
Serialized JSON
var obj = new CB.CloudObject('Sample');
CB.toJSON(obj);
json )Convert JSON to CloudBoost Objects
Serialized JSON
CB.fromJSON({/*Serialized JSON*/});
We heart contributors. Love what we do and want to contribute?
JavaScript SDK :
GitHub Repository
Our documentation is open source too!
Documentation : GitHub Repository
01001101 01100001 01100100 01100101
01110111 01101001 01110100 01101000
00111100 00110011