Database
Service URI - luna://com.palm.db
Enables apps to store persistent data.
DB8 is an API for managing an embedded JSON database. DB8 allows apps to store persistent data. DB8 provides various functions that allow entry, storage, and retrieval of large quantities of information as well as ways to manage how that information is organized.
It provides the following data management functions:
Add objects
Update objects
Delete objects
Query objects
Manage access to objects within the database
To learn about webOS Database (DB8) service and how to use it, see Database (DB8).
Methods
Method | Description | Supported in Emulator |
|---|---|---|
Enables apps to execute multiple database operations in one service request. | Yes | |
Deletes the JSON data objects from the database. | Yes | |
Deletes a kind from the database. | Yes | |
Returns a set of objects that match the `query` specified in the `query` parameter. | Yes | |
Retrieves JSON data objects by IDs. | Yes | |
Updates the object properties in existing objects. | Yes | |
Stores JSON data objects of a particular kind into the database. | Yes | |
Registers a kind with the database. | Yes | |
Enables other apps or services to access the app's stored DB8 data. | Yes | |
Reserves a block of object IDs. | Yes | |
Supports the `?` operator which is used for full-text searching. | Yes | |
Watches for updates to the database that would change the results of a query. | Yes |
batch
Description
Enables apps to execute multiple database operations in one service request. It allows only the following database operations:
put
get
del
find (without a watch)
merge
Atomicity is NOT guaranteed across batched operations.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
Yes | Object array | The list of database operations to perform. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the method succeeds, it will return the `BatchResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3984 | No required key: `method` | The required database operations name is missing. |
-3984 | No required key: `params` | The required parameters for a database operation are missing. |
-3982 | db: invalid operation in batch | An incorrect or an unsupported database operation was specified in the `operations` parameter. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'batch',
parameters: {
operations: [
{
method: 'put',
params: {
objects: [
{
_kind: 'com.yourdomain.test:1',
sample: 'sample1',
test: 'test1',
},
],
},
},
{
method: 'merge',
params: {
query: {
from: 'com.yourdomain.test:1',
where: [
{
prop: 'sample',
op: '=',
val: 'sample1',
},
],
},
props: {
sample: 'sample2',
test: 'test2',
},
},
},
],
},
onSuccess: function (inResponse) {
console.log('The batch work is executed');
console.log(JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to execute the batch work');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
{
"responses": [
{
"returnValue": true,
"results": [
{
"id": "JHd3Dg427oB",
"rev": 21868
}
]
},
{
"count": 1,
"returnValue": true
}
],
"returnValue": true
}
See also
del
Description
Deletes the JSON data objects from the database. Apps can specify the objects as:
A set of IDs
A DB8 query
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
ids | No | String array | An array of JSON object ids that you wish to delete. If you do not wish to specify JSON object ids, you must specify a `query` in the `query` parameter. |
No | Object | A query for a set of objects to be deleted. If you do not wish to specify a query, you must specify a list of JSON object ids in the `ids` parameter. | |
purge | No | Boolean | The default value is `false`.
|
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | When the method succeeds, and the objects to be deleted were specified as a list of JSON object ids, it will return the `PutResponse` object. | |
No | Object | When the method succeeds, and the objects to be deleted were specified as a query, it will return the `CountResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3963 | db: permission denied | The app does not have permission to delete the specified object. |
-3965 | db: no index for query | The query is referring to an index that does not exist for the specified kind. |
-3962 | db: quota exceeded | There is no space left on the device to complete this operation. It is recommended that the app should call the method again with `purge` set to `true`. |
Example
// Delete data with ID
var request = webOS.service.request('luna://com.palm.db', {
method: 'del',
parameters: {
ids: ['JHd3Dg427oB'],
},
onSuccess: function (inResponse) {
console.log('The ' + inResponse.results.id + 'object is deleted');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to delete the object');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
// Delete data with query
// Delete all data object from com.yourdomain.test:1 kind
var request = webOS.service.request('luna://com.palm.db', {
method: 'del',
parameters: {
query: {
from: 'com.yourdomain.test:1',
},
},
onSuccess: function (inResponse) {
console.log('The ' + inResponse.count + 'object(s) is(are) deleted');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to delete the object');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
// Result: Delete with ID
{
"returnValue": true,
"results": [
{
"id": "J8rBI6u7uh+"
}
]
}
// Result: Delete with Query
{
"count": 11,
"returnValue": true
}See also
delKind
Description
Deletes a kind from the database. Deleting a kind deletes ALL data objects of that kind.
Parameters
Name | Required | Type | Description |
|---|---|---|---|
id | Yes | String | The id of the kind that the app wants to delete. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
errorCode | No | Number | `errorCode` contains the error code if the method fails. The method returns `errorCode` only if it fails. See the Error code reference of this method for more details. |
errorText | No | String | `errorText` contains the error text if the method fails. The method returns `errorText` only if it fails. See the Error code reference of this method for more details. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3970 | db: kind not registered | The specified kind doesn't exist in the database. |
-3999 | db: access denied | The specified kind exists in the database, however, the app does not have the delete permissions. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'delKind',
parameters: {
id: 'com.yourdomain.test:1',
},
onSuccess: function (inResponse) {
console.log('The kind is deleted');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to delete the kind');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});See also
find
Description
Returns a set of objects that match the query specified in the `query` parameter.
The app can specify the number of results to return. However, if the app does not want to specify a limit, it can set the `count` parameter to `true`. This will cause the `find` method to return the total number of results returned in the `FindResponse` object.
The app can also request to be notified if any of the returned results from the query change in the future. In order to receive change notifications, set the `watch` parameter to `true`.
The `find` method supports group by(distinct) enabling the app to remove duplicate objects.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
Yes | Object | DB8 query for retrieving results. | |
count | No | Boolean | The default value of the `count` parameter is `false`. If the app does not specify a limit on the number of results to return and wants to know the total number of results returned, the app should set the `count` parameter to `true`. |
watch | No | Boolean | The default value of the `watch` parameter is `false`. If an app wants to be notified about any changes in the returned results, the app should set the `watch` parameter to `true`. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the `find` method succeeds, the `find` method returns the `FindResponse` object. | |
No | Object | If the `watch` parameter was set to `true` by the app, the `find` method returns the `NotificationResponse` object. | |
No | Object | If the `find` method fails, it returns the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3970 | db: kind not registered | The specified kind is not registered in the database. |
-3978 | db: invalid query | The query syntax is correct, but contains misspelled commands or logical errors. |
-3965 | db: no index for query | The SELECT query contains field name(s) that do not exist for the selected kind. |
-3963 | db: permission denied | The specified kind exists in the database, however, the app does not have permissions to read the data for the specified kind. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'find',
parameters: {
query: {
from: 'com.yourdomain.test:1',
where: [{ prop: 'sample', op: '=', val: 'sample1' }],
},
},
onSuccess: function (inResponse) {
console.log(inResponse.results.length + ' object(s) is(are) found');
console.log('Result: ' + JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to find the object with query');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});Return example
{
"returnValue": true,
"results": [
{
"_rev": 21873,
"sample": "sample2",
"test": "test2",
"_id": "JHdxo18aqjZ",
"_kind": "com.yourdomain.test:1"
},
{
"_rev": 21875,
"sample": "sample2",
"test": "test2",
"_id": "JHdyO1clmYs",
"_kind": "com.yourdomain.test:1"
}
]
}See also
get
Description
Retrieves JSON data objects by ids. This is the fastest way to retrieve data.
Parameters
Name | Required | Type | Description |
|---|---|---|---|
ids | Yes | String array | Ids of the JSON data objects to retrieve. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the method succeeds, it will return the `GetResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3999 | db: access denied | The specified object exists in the database, but the app does not have permissions to access the object. |
-3950 | db: I/O error | It is not possible to read from the database and this is a critical error. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'get',
parameters: {
ids: ['J8rKTaBClIo'],
},
onSuccess: function (inResponse) {
console.log(inResponse.results.length + ' object(s) is(are) retrieved');
console.log('Result: ' + JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to get the object(s)');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
{
"returnValue": true,
"results": [
{
"_rev": 21,
"sample": "sample1",
"test": "test1",
"_id": "J8rKTaBClIo",
"_kind": "com.yourdomain.test:1"
}
]
}See also
merge
Description
Updates the object properties in existing objects.
The objects can be specified in one of the following ways.
A query
An array of IDs
Objects can be specified using a query (returns `CountResponse`) or array of IDs (returns `PutResponse`).
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
objects | No | Object array | The `objects` parameter is an array of objects, and each object will have an id and key/value pairs that represent the object properties that the app needs to merge. The `objects` parameter is required if the `query` parameter is not specified. |
No | Object | Query object specifying the set of objects whose properties the app wants to update. The `query` parameter is required if the `objects` parameter is not specified. | |
props | No | Object | The `props` parameter is an object with key/value pairs that specify the set of properties to be merged into the existing object(s) specified in the `query` parameter. If the app specifies the properties in the `props` parameter, the `query` is required. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the `objects` parameter was specified, and the method succeeds, it will return the `PutResponse` object. | |
No | Object | If the `query` parameter was specified, and the `merge` method succeeds, it will return the `CountResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3961 | db: quota exceeded | The app has exceeded its quota or there is no free space available on the device. |
-3963 | db: permission denied | The app does not have permission to modify the specified objects. |
-3965 | db: no index for query | The query contains a SELECT for object properties that do not have an index associated with them. |
Example
// Update object with ids and values
var request = webOS.service.request('luna://com.palm.db', {
method: 'merge',
parameters: {
objects: [
{
_id: 'J8rKTaBClIo',
test: 'test1',
sample: 'sample_updated_value',
},
],
},
onSuccess: function (inResponse) {
console.log('The object(s) is(are) updated');
console.log('Result: ' + JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to update the object(s)');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
// Update data with query
var request = webOS.service.request('luna://com.palm.db', {
method: 'merge',
parameters: {
query: {
from: 'com.yourdomain.test:1',
where: [
{
prop: 'sample',
op: '=',
val: 'sample1',
},
],
},
props: {
sample: 'sample_updated_value',
},
},
onSuccess: function (inResponse) {
console.log(inResponse.count + ' object(s) is(are) updated');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to update the object(s)');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
// Return: Update object with ids and values
{
"returnValue": true,
"results": [
{
"id": "J8rKTaBClIo",
"rev": 23
}
]
}
// Return: Update data with query
{
"count": 2,
"returnValue": true
}See also
put
Description
Stores JSON data objects of a particular kind into the database. The `put` method will:
Assign an `id` field to each object, if it was not set
Return the `id` and `rev` for each stored object
Parameters
Name | Required | Type | Description |
|---|---|---|---|
objects | Yes | Object array | List of JSON data objects of a particular kind that the app wants to store in the database. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the method succeeds, it will return the `PutResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3962 | db: quota exceeded | The app has exceeded its quota or there is no free space available on the device. |
-3970 | db: kind not registered | The kind for the specified object is not registered with the database. |
-3963 | db: permission denied | The app does not have permission to save objects of a specified kind. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'put',
parameters: {
objects: [
{
_kind: 'com.yourdomain.test:1',
sample: 'sample1',
test: 'test1',
},
],
},
onSuccess: function (inResponse) {
console.log('The object(s) is(are) added');
console.log('Result: ' + JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to add the object(s)');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
{
"returnValue": true,
"results": [
{
"id": "J8rTIa65u++",
"rev": 27
}
]
}See also
putKind
Description
Registers a kind with the database.
Kinds define the owner, and the indexes for a JSON data object. Indexes can be composed of single or multiple properties. When you create your index, be aware that queries can only return results that are indexed, and are contiguously ordered.
If your app or service wants to be notified only when a subset of an object's properties is updated, then you can use revision sets.
If your app or service creates objects that other apps or services need to access, then see the putPermissions method for more information.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
id | Yes | String | Id of the kind. |
owner | Yes | String | Owner of the kind. Possible values:
|
private | No | Boolean | The `private` parameter is available on webOS TV 3.0 or later.
|
schema | No | Object | If you define the schema, you must put the valid data that conforms to the schema format. For more information about the schema, see Schema Enforcement. |
sync | No | Boolean | Enables apps to enable backing up and restoring specific kinds of objects. The default value for the parameter is `false`. If the app wants to enable backing up and restoring objects to LG servers on a daily basis, the app should set `sync` to `true`. If the user moves to another device, the saved app data can be restored. |
extends | No | String array | List of the ids of kind parents. |
No | Object | The kind indexes. | |
No | Object array | List of database revision sets. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
errorCode | No | Number | `errorCode` contains the error code if the method fails. The method returns `errorCode` only if it fails. See the Error code reference of this method for more details. |
errorText | No | String | `errorText` contains the error text if the method fails. The method returns `errorText` only if it fails. See the Error code reference of this method for more details. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3981 | db: invalid owner for kind | The specified owner does not have permissions to add or modify the specified kind. |
-3962 | db: quota exceeded | App has exceeded its quota or does not have enough disk space available to create the specified kind. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'putKind',
parameters: {
id: 'com.yourdomain.test:1',
owner: 'com.yourdomain.test',
private: true,
indexes: [
{
name: 'sample',
props: [{ name: 'sample' }],
},
{
name: 'testsample',
props: [{ name: 'test' }, { name: 'sample' }],
},
],
},
onSuccess: function (inResponse) {
console.log('The kind is created');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to create the kind');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
See also
putPermissions
Description
Enables other apps or services to access the apps stored DB8 data. The app can give permissions to access data objects of a particular kind.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
type | Yes | String | Must be set to db.kind. |
object | Yes | String | The DB8 kind of the object for which the app wants to provide access. |
caller | Yes | String | The id of the app or service that the app is granting permission to access its data. |
Yes | Object | Database operations the app is granting permissions for. | |
create | No | String | To grant create permission, set the `create` parameter to allow. |
read | No | String | To grant read permission, set the `read` parameter to allow. |
update | No | String | To grant update permission, set the `update` parameter to allow. |
delete | No | String | To grant delete permission, set the `delete` parameter to allow. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
errorCode | No | Number | `errorCode` contains the error code if the method fails. The method returns `errorCode` only if it fails. See the Error code reference of this method for more details. |
errorText | No | String | `errorText` contains the error text if the method fails. The method returns `errorText` only if it fails. See the Error code reference of this method for more details. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3999 | db: access denied | The app cannot modify the permissions of the specified kind |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'putPermissions',
parameters: {
permissions: [
{
operations: {
read: 'allow',
create: 'allow',
update: 'allow',
delete: 'allow',
},
object: 'com.yourdomain.test:1',
type: 'db.kind',
caller: 'com.yourdomain.testapp',
},
],
},
onSuccess: function (inResponse) {
console.log('The permission(s) is(are) set');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to set the permission(s)');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
See also
reserveIds
Description
Reserves a block of object ids.
Parameters
Name | Required | Type | Description |
|---|---|---|---|
count | Yes | Number | Number of Ids to reserve. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the method succeeds, it will return the `ReserveIdsResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3968 | db: malformed id | The specified count contains an invalid value. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'reserveIds',
parameters: {
count: 3,
},
onSuccess: function (inResponse) {
console.log(inResponse.ids.length + ' object ID(s) is(are) reserved');
console.log('Result: ' + JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to reserve object IDs');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
{
"ids": [
"J9FJ12j0Usk",
"J9FJ12j18hJ",
"J9FJ12j1Mic"
],
"returnValue": true
}
See also
search
Description
Supports the `?` operator. The `?` operator can be used for full-text searching. However, the `search` method is significantly slower, and should only be used for a full-text type-down search. The `search` method should not be used for retrieving results that are going to be scrolled in a list.
The `search` method supports:
Ordering by any property
Distinct method to remove duplicate objects
`%%` operator in the filter to search in a substring
The `search` method has some limitations:
There must be an index for the field you are searching on.
The search operation looks for words beginning with the search string.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
Yes | Object | Query for search. | |
watch | No | Boolean | The default value of the `watch` parameter is `false`. If the app wants to be notified of any changes in the search results, it should set the `watch` parameter to `true`. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If the method succeeds, it will return the `FindResponse` object. | |
No | Object | If the method succeeds and the app had set the `watch` parameter to `true`, the search will return the `NotificationResponse` object. | |
No | Object | If the method fails, it will return the `ErrResponse` object. |
Error code reference
Error Code | Error Message | Error Description |
|---|---|---|
-3987 | db: invalid filter op | An invalid operation was specified in the filter. |
-3978 | db: invalid query | There was a syntax error in the query. |
-3977 | db: collations on property do not match | The collation sequence of a property across different objects does not match. |
-3975 | db: invalid combination of query operations | The query syntax is correct, but contains logical errors. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'search',
parameters: {
query: {
from: 'com.yourdomain.test:1',
where: [
{
prop: 'sample',
op: '?',
val: 'sample',
},
],
},
},
onComplete: function (inResponse) {
console.log(inResponse.count + ' objects is(are) returned.');
console.log('Results: ' + JSON.stringify(inResponse));
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to search');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
Return example
{
"count": 4,
"returnValue": true,
"results": [
{
"_rev": 22,
"sample": "sample_updated_value",
"test": "test1",
"_id": "J8rKQDOvxdF",
"_kind": "com.yourdomain.test:1"
},
{
"_rev": 23,
"sample": "sample_updated_value",
"test": "test1",
"_id": "J8rKTaBClIo",
"_kind": "com.yourdomain.test:1"
},
{
"_rev": 26,
"sample": "sample1",
"test": "test1",
"_id": "J8rTH76hfcB",
"_kind": "com.yourdomain.test:1"
},
{
"_rev": 27,
"sample": "sample1",
"test": "test1",
"_id": "J8rTIa65u++",
"_kind": "com.yourdomain.test:1"
}
]
}See also
watch
Description
Watches for updates to the database that would change the results of a query.
Parameters
| Name | Required | Type | Description |
|---|---|---|---|
Yes | Object | Query whose results the app wants to watch. |
Call returns
| Name | Required | Type | Description |
|---|---|---|---|
No | Object | If DB8 has enough resources to add the client to "watch stack" and the `watch` method succeeds, it returns the `SuccessResponse` object. | |
No | Object | If DB8 has enough resources to add into "watch stack" and DB8 found some record for the query, it returns the `NotificationResponse` object. | |
No | Object | If the method fails, it returns the `ErrResponse` object. |
Error code reference
Error code | Error message | Error description |
|---|---|---|
-3999 | db: access denied | The app does not have permissions to monitor the database. |
Example
var request = webOS.service.request('luna://com.palm.db', {
method: 'watch',
parameters: {
query: {
from: 'com.yourdomain.test:1',
where: [
{
prop: 'sample',
op: '=',
val: 'sample1',
},
],
},
},
onSuccess: function (inResponse) {
console.log('The object, which is met specified criteria, was found.');
// To-Do something
},
onFailure: function (inError) {
console.log('Failed to watch');
console.log('[' + inError.errorCode + ']: ' + inError.errorText);
// To-Do something
return;
},
});
{
"returnValue": true,
"fired": true
}See also
Object
BatchOperation object
The object for batch operation.
{
"method" : string,
"params" : any
}| Name | Required | Type | Description |
|---|---|---|---|
method | Yes | String | Database operation to perform. Allowed values are:
|
params | Yes | String | List of parameters for the database operation. |
BatchResponse object
Response to batch operation.
{
"returnValue": boolean,
"responses" : any array
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
responses | Yes | Array | Array of responses for each of the operations in the batch. |
ErrResponse object
Standard error response, containing operation success or failure flag, error code and error message.
{
"returnValue": boolean,
"errorCode" : int,
"errorText" : string
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
If the method fails, the method will return an error message description in `errorCode` and `errorText` fields respectively. |
errorCode | Yes | Number | Numeric error code. |
errorText | Yes | String | Error message from the service. This property is available when a request fails. |
Query object
Defines a DB8 query.
// Schema
{
"select" : string array,
"from" : string,
"where" : WhereClause array,
"orderBy" : string,
"desc" : boolean,
"incDel" : boolean,
"limit" : int,
"page" : string
}
// Example
{
"select" : ["displayName", "state"],
"from" : "com.mystuff.contacts:1",
"where" : [{"prop":"state","op":"=","val":"CA"}],
"orderBy" : "displayName",
"desc" : true
}| Name | Required | Type | Description |
|---|---|---|---|
select | No | String array | Array of property names to return. |
from | Yes | String | Name of the kind to retrieve results from. |
No | Object array | Array of clauses to test. | |
orderBy | No | String | Order results on this property. |
desc | No | Boolean | If set to `true`, query results will be returned in a descending order. |
incDel | No | Boolean | If `incDel` is `true`, the query results will include deleted objects. Note You can only request this if the `incDel` field was `true` when the indexes were created during a `putKind` operation. Otherwise, the query fails with a "no index for this query" message. |
limit | No | Number | Specifies the maximum number of results to return (0-500). The default is 500. |
page | No | String | Page key returned by the previous query. |
No | Object array | Array of clauses - works only in the search method - identical to `WhereClause`. Can be used along with `where` to perform a range search. |
PutResponse object
Indicates success of the operation and returns `id` and `rev` fields for each object.
{
"returnValue" : boolean,
"results" : PutResult
} | Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
Yes | Object array | Array of objects containing the `id` and `rev` of each object that was put. |
CountResponse object
The number of objects affected by the operation.
{
"returnValue" : boolean,
"count" : int
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
count | Yes | Number | Number of objects affected by operation. |
FindResponse object
Response to a find objects operation.
{
"returnValue" : boolean,
"results" : any,
"count" : int,
"next" : string
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
results | Yes | Any | Array of DB8 kind data objects. What is returned depends on the query and what is stored. |
count | No | Number | Number of results that would have been returned if a limit had not been specified. |
next | No | String | Key to pass as query's `page` property when retrieving next page of results. |
NotificationResponse object
Notifies caller of change in query results returned from a `find` call.
{
"returnValue" : boolean,
"fired" : boolean
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | No | Boolean | Flag that indicates success/failure of the request.
|
fired | Yes | Boolean | Change notification flag. |
GetResponse object
Parameters for get objects operation response.
{
"returnValue" : boolean,
"results" : any
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
results | Yes | Object array | Returns array of stored DB8 data objects. |
IndexClause object
Used in the `putKind` call for creating kind object indexes. Note that indexes determine the type of queries your app can make. See Queries and Indexing for more information. Set the `incDel` flag to `true` if you want future queries to return marked as deleted objects. Objects are not completely deleted until an administrative purge operation takes place.
//Schema
{
"name" : string,
"props" : IndexPropClause,
"incDel" : boolean
}
//Example
{
"name" : "state",
"props" : [{"name": "state"}],
"incDel" : false
}| Name | Required | Type | Description |
|---|---|---|---|
name | Yes | String | Index name. |
Yes | Object array | Array of properties to index together. | |
incDel | No | Boolean | If `incDel` is `true`, the query results will include the deleted object. Note You can only request this if the `incDel` field was `true` when you created your indexes during a `putKind` operation. Otherwise, the query fails with a "no index for this query" message. |
RevSetClause object
Defines a revision set- a subset of an object's properties that your app can be notified about when one of the properties is modified. See Change Notification for more information.
// Schema
{
"name" : string,
"props" : RevSetPropClause array
}| Name | Required | Type | Description |
|---|---|---|---|
name | Yes | String | Name of the revision set (unique to this kind). |
Yes | Object array | Array of properties to include in revision set. |
operation object
The object used to represent a batch operation to run.
(This object has a different format per product. The following object example is for TV product).
{
"method" : string,
"params" : []
}Name | Required | Type | Description |
|---|---|---|---|
method | Yes | String | Operation being requested. |
params | Yes | Any array | Params will depend on the type of operation being requested |
ReserveIdsResponse object
Contains operation success or failure flag and the array of reserved db8 IDs returned from `reserveIds` call.
{
"returnValue" : boolean,
"ids" : string array
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
ids | No | String array | Array of reserved IDs. |
SuccessResponse object
Indicates operation success or failure.
// Schema
{
"returnValue" : boolean
}
// Example
{
"returnValue": false
}| Name | Required | Type | Description |
|---|---|---|---|
returnValue | Yes | Boolean | Flag that indicates success/failure of the request.
|
WhereClause object
Defines a SQL-like JSON where clause for a DB8 Query.
// Schema
{
"prop" : string,
"op" : string,
"val" : any,
"collate" : string
}
// Example
{
"prop" : "state",
"op" : "=",
"val" : "CA"
}Name | Required | Type | Description |
|---|---|---|---|
prop | Yes | String | Name of property to test. |
op | Yes | String | Test operator. Must be one of the following: <, <=, =, >=, >, !=, %, ?, %% (less than, less than or equal, equals, greater than or equal, greater than, not equal, wildcard, and full-text) The `%` operator (aka - the prefix operator) will return all matches beginning with the value specified. The `%%` operator is used to locate substrings or partial string matches. |
val | Yes | Any | Value to test against. |
collate | No | String | Indicates the string comparison routine used to order the results. See the `collate` field in the `IndexPropClause` data structure for more information. |
FilterClause object
Definition of the Filter clause that is part of the Query object.
// Schema
{
"prop" : string,
"op" : string,
"val" : any,
"collate" : string
}
// Example
{
"prop" : "state",
"op" : "=",
"val" : "CA"
}| Name | Required | Type | Description |
|---|---|---|---|
prop | Yes | String | Name of property to test. |
op | Yes | String | Test operator. Must be one of the following: <, <=, =, >=, >, !=, ?, %, %% (less than, less than or equal, equals, greater than or equal, greater than, not equal, wildcard, full-text, and partial-text) The `%` operator (aka - the prefix operator) will return all matches beginning with the value specified. The `%%` operator is used to locate substrings or partial string matches. |
val | Yes | Any | Value to test against. |
collate | No | String | Indicates the string comparison routine used to order the results. See the `collate` field in the IndexPropClause data structure for more information. |
PutResult object
Contains `id` and `rev` fields in `PutResponse` for JSON data object.
// Schema
{
"id" : any,
"rev" : any
} Name | Required | Type | Description |
|---|---|---|---|
id | Yes | Any | ID of the object that was put. |
rev | Yes | Any | Object's revision ID. Every DB8 object has this ID field. DB8 maintains a global `rev` ID counter that is incremented every time a DB8 object is created or updated. |
IndexPropClause object
Defines index property for IndexClause.
// Schema
{
"name" : string,
"collate" : string,
"default" : any,
"tokenize" : string,
"type" : string
}| Name | Required | Type | Description |
|---|---|---|---|
name | Yes | String | Name of property being indexed. |
collate | Yes | String | Indicates the string comparison routine used to order the index. Must be one of the following:
|
default | No | Any | Default value to set for this property at insertion time, if not present. |
tokenize | No | String | Indicates if words in strings should be broken up, i.e., should "Hello World" become "Hello" and "World" for purposes of indexing. Must be one of the following:
|
type | Yes | String | `single` or `multi`. Single property or multiple properties. |
RevSetPropClause object
Object for RevSetPropClause.
{
"name" : string
}Name | Required | Type | Description |
|---|---|---|---|
name | Yes | String | Name of property to include in revision set. |