Custom Objects Module
Methods
-
staticQB.data.create(className, data, callback)
modules/qbData.js, line 44 -
Create new custom object(read more).
Name Type Description className
string A class name to which a new object belongs. data
object Object of parameters (custom fields' names and their values). callback
createDataCallback The createDataCallback function. Example
var data = { 'name': 'John', 'age':'20', 'family': [ 'Stark', 'Targaryen' ] }; function createdDataCallback(error, response) { if (error) { console.log(error); } else { console.log(response); } } QB.data.create('GameOfThrones', data, createdDataCallback);
-
staticQB.data.delete(className, requestedData, callback)
modules/qbData.js, line 206 -
Delete record/records by ID, IDs or criteria (filters) of particular class(read more).
Name Type Description className
string A class name of record. requestedData
string | array | object An ID of record or an array of record's ids or object of criteria rules to delete. callback
deletedDataCallback The deletedDataCallback function. Example
var className = 'Movie'; function deletedMovie(error, responce) { if(error) { throw new Error(error.toString()); } else { console.log(`Deleted movies with ids: ${responce.deleted.toString()}`); } } // By ID, must be string var id = '502f7c4036c9ae2163000002'; QB.data.delete(className, id, deletedMovie); // By IDs, must be array var ids = ['502f7c4036c9ae2163000002', '502f7c4036c9ae2163000003']; QB.data.delete(className, ids, deletedMovie); var criteria = { 'price': { 'gt': 100 }; function deletedMoviesByCriteria(error, responce) { if(error) { throw new Error(error.toString()); } else { // Note! Deleted by creteria doesn't return ids of deleted objects console.log(`Deleted ${responce.deletedCount} movies`); } } QB.data.delete(className, criteria, deletedMoviesByCriteria);
-
staticQB.data.deleteFile(className, params, callback)
modules/qbData.js, line 361 -
Delete file from file field by ID(read more).
Name Type Description className
string A class name of record. params
object Object of parameters. Name Type Description field_name
string The file's field name. id
string The record's ID. callback
deleteFileFromDataCallback The deleteFileFromDataCallback function. -
staticQB.data.downloadFile(className, params, callback)
modules/qbData.js, line 326 -
Download file from file field by ID(read more).
Name Type Description className
string A class name of record. params
object Object of parameters. Name Type Description field_name
string The file's field name. id
string The record's ID. callback
downloadFileFromDataCallback The downloadFileFromDataCallback function. -
staticQB.data.fileUrl(className, params)
modules/qbData.js, line 346 -
Return file's URL from file field by ID.
Name Type Description className
string A class name of record. params
object Object of parameters. Name Type Description field_name
string The file's field name. id
string The record's ID. -
staticQB.data.list(className, filters, callback)
modules/qbData.js, line 100 -
Search for records of particular class(read more).
Name Type Description className
string A class name to which a new record belongs. filters
object | Array.<string> Search records with field which contains exactly specified value or by array of records' ids to retrieve. Name Type Default Description skip
number 0 optional Skip N records in search results. Useful for pagination. Default (if not specified) - 0. limit
number 100 optional Limit search results to N records. Useful for pagination. Default and max values - 100. If limit is equal to -1 only last record will be returned. *
string optional See more filters' parameters. callback
listOfDataCallback The listOfDataCallback function. Example
var filter = { 'skip': 0, 'limit': 100, 'sort_desc': 'updated_at', 'family': { 'in': 'Stark,Targaryen' } }; var ids = ['53aaa06f535c12cea9007496', '53aaa06f535c12cea9007495']; // use filter or ids to get records: QB.data.list('GameOfThrones', filter, function(error, response) { if (error) { console.log(error); } else { console.log(response); } });
-
staticQB.data.update(className, data, callback)
modules/qbData.js, line 143 -
Update record by ID of particular class(Read more).
Name Type Description className
string A class name of record. data
object Object of parameters. Name Type Description _id
string An ID of record to update. callback
updateDataCallback The updateDataCallback function. Example
QB.data.update('GameOfThrones', { '_id': '53aaa06f535c12cea9007496', 'pull': { 'family':'Stark' } }, function(error, response) { if (error) { console.log(error); } else { console.log(response); } });
-
staticQB.data.uploadFile(className, params, callback)
modules/qbData.js, line 287 -
Upload file to file field(read more).
Name Type Description className
string A class name to which a new object belongs. params
object Object of parameters. Name Type Description field_name
string optional The file's field name. name
string optional The file's name. file
object optional File object. callback
uploadFileToDataCallback The uploadFileToDataCallback function.