Media Database

Service URI - luna://com.webos.mediadb

Enables apps to store large media-related datasets persistently.

The Media Database service enables apps to:

  • Add objects
  • Update objects
  • Delete objects
  • Query objects
  • Manage access to objects within the database

Unlike the DB8 service, Media Database allows apps to manage large media datasets.

However, the usage method of Media Database is as same as Database (DB8). To learn about webOS Database (DB8) service and how to use it, see Database (DB8).

Methods

MethodDescriptionSupported in Emulator
batchEnables apps to execute multiple database operations in one service request.Yes
delDeletes the JSON data objects from the database.Yes
delKindDeletes a kind from the database.Yes
findReturns a set of objects that match the query specified in the query parameter.Yes
getRetrieves JSON data objects by ids.Yes
mergeUpdates the object properties in existing objects.Yes
putStores JSON data objects of a particular kind into the database.Yes
putKindRegisters a kind JSON object with the database.Yes
putPermissionsEnables other apps, or services to access the apps stored DB8 data.Yes
reserveIdsReserves a block of object ids.Yes
searchSupports the ? operator which is used for full-text searching.Yes
watchWatches 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

NameRequiredTypeDescription
operationsRequiredObject arrayThe list of database operations to perform.

Call returns

NameRequiredTypeDescription
BatchResponseOptionalObjectIf the method succeeds, it will return BatchResponse object.
ErrResponseOptionalObjectIf the method fails, it will return ErrResponse object.

Error reference

Error CodeError MessageError Description
-3984No required key: "method"The required database operations name is missing.
-3984No required key: "params"The required parameters for a database operation is missing.
-3982db: invalid operation in batchAn 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 excuted');
    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 - this will return a PutResponse object
  • a DB8 query - this will return a CountResponse object

Parameters

NameRequiredTypeDescription
idsOptionalString arrayAn 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.
queryOptionalObjectA 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.
purgeOptionalBooleanThe default value is false.
  • false: The target objects will only be marked for deletion. Objects marked for deletion can still be restored. They will be purged permanently only when an administrative purge operation is run.
  • true: The target objects will be deleted permanently immediately.

Call returns

NameRequiredTypeDescription
PutResponseOptionalObjectWhen the method succeeds, and the objects to be deleted were specified as a list of JSON object ids, it will return PutResponse object.
CountReponseOptionalObjectWhen the method succeeds, and the objects to be deleted were specified as a query, it will return CountResponse object.
ErrResponseOptionalObjectIf the method fails, it will return ErrResponse object.

Error reference

Error CodeError MessageError Description
-3963db: permission deniedThe app does not have permission to delete the specified object.
-3965db: no index for queryThe query is referring to an index that does not exist for the specified kind.
-3962db: quota exceededThere 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 obejct");
		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 obejct");
		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

NameRequiredTypeDescription
idRequiredStringThe id of the kind that the app wants to delete

Call returns

NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalNumbererrorCode contains the error code if the method fails. The method will return errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalStringerrorText contains the error text if the method fails. The method will return errorText only if it fails.
See the Error Codes Reference of this method for more details.

Error reference

Error CodeError MessageError Description
-3970db: kind not registeredThe specified kind doesn't exist in the database.
-3999db: access deniedThe 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 distinct groups enabling the app to remove duplicate objects.

Parameters

NameRequiredTypeDescription
queryRequiredObjectDB8 query for retrieving results.
countOptionalBooleanThe default value is false.
If the app did 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.
watchOptionalBooleanThe default value is false.
If an app wants to be notified about any change in the returned results, the app should set the watch parameter to true.

Call returns

NameRequiredTypeDescription
FindResponseOptionalObjectIf the method succeeds, it will return the FindResponse object.
NotificationResponseOptionalObjectIf the watch parameter was set to true by the app, the find method will return the NotificationResponse object.
ErrResponseOptionalObjectIf the method fails, it will return the ErrResponse object.

Error reference

Error CodeError MessageError Description
-3970db: kind not registeredThe specified kind is not registered in the database.
-3978db: invalid queryThe query syntax is correct, but contains misspelled commands or logical errors.
-3965db: no index for queryThe SELECT query contains field name(s) that do not exist for the selected kind.
-3963db: permission deniedThe 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 obejct 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

NameRequiredTypeDescription
idsRequiredString arrayIds of the JSON data objects to retrieve.

Call returns

NameRequiredTypeDescription
GetResponseOptionalObjectIf the method succeeds, it will return the GetResponse object.
ErrResponseOptionalObjectIf the method fails, it will return the ErrResponse object.

Error reference

Error CodeError MessageError Description
-3999db: access deniedThe specified object exists in the database, but the app does not have permissions to access the object.
-3950db: I/O errorIt is not possible to read from the database and that 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 obejct(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

NameRequiredTypeDescription
objectsOptionalObject arrayList of object ids, and the properties the app needs to merge. The objects parameter is required if the query parameter is not specified.
queryOptionalObjectQuery specifying the set of an object whose properties the app wants to update.
The query parameter is required if the object parameter is not specified.
propsOptionalObjectThe props parameter should 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 prop parameter, the query is required.

Call returns

NameRequiredTypeDescription
PutResponseOptionalObjectIf the objects parameter was specified, and the merge method succeeds, merge will return the PutResponse object.
CountResponseOptionalObjectIf the query parameter was specified, and the merge method succeeds, merge will return the CountResponse object.
ErrResponseOptionalObjectIf the merge method fails, it will return the ErrResponse object.

Error reference

Error CodeError MessageError Description
-3961db: quota exceededThe app has exceeded its quota or there no free space is available on the device.
-3963db: permission deniedThe app does not have permission to modify the specified objects.
-3965db: no index for queryThe 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 obejct(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 obejct(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

NameRequiredTypeDescription
objectsRequiredObject arrayList of JSON data objects of a particular kind that the app wants to store in the database.

Call returns

NameRequiredTypeDescription
PutResponseOptionalObjectIf the method succeeds, it will return PutResponse object.
ErrResponseOptionalObjectIf the method fails it will return ErrResponse object.

Error reference

Error CodeError MessageError Description
-3962db: quota exceededThe app has exceeded its quota or there no free space is available on the device.
-3970db: kind not registeredThe kind for the specified object is not registered with the database.
-3963db: permission deniedThe 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 obejct(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 JSON object with the database.
Kind objects define the owner, and the indexes for a JSON data object. Indexes can be composed of single or multiple fields. 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 are 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

NameRequiredTypeDescription
idRequiredStringId of the kind JSON object
ownerRequiredStringOwner of the kind JSON object. Possible values:
  • The service's bus address, or,
  • The app's app ID
Only the owner has permission to modify the kind JSON object.
schemaOptionalObjectJSON Syntax for data objects of a specific kind. If set, this kind's data objects are validated before being stored. For details refer to http://www.json.org/.
syncOptionalBooleanNot supported by this version of DB8.
The default value is false.
extendsOptionalString arrayList of the ids of kind parents
indexesOptionalObjectKind indexes
revsetsOptionalObject arrayList of database revision sets

Call returns

NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalNumbererrorCode contains the error code if the method fails. The method will return errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalStringerrorText contains the error text if the method fails. The method will return errorText only if it fails.
See the Error Codes Reference of this method for more details.

Error reference

Error CodeError MessageError Description
-3981db: invalid owner for kindThe specified owner does not have permissions to add or modify the specified kind.
-3962db: quota exceededApp 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',
    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

NameRequiredTypeDescription
typeRequiredStringMust be set to db.kind.
objectRequiredStringThe DB8 kind of the object for which the app wants to provide access.
callerRequiredStringThe id of the app or service that the app is granting permission to access its data.
operationsRequiredObjectDatabase operations the app is granting permissions for.
createOptionalStringTo grant create permission, set the value to allow.
readOptionalStringTo grant read permission, set the value to allow.
updateOptionalStringTo grant update permission, set the value to allow.
deleteOptionalStringTo grant delete permission, set the value to allow.

Call returns

NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeOptionalNumbererrorCode contains the error code if the method fails. The method will return errorCode only if it fails.
See the Error Codes Reference of this method for more details.
errorTextOptionalStringerrorText contains the error text if the method fails. The method will return errorText only if it fails.
See the Error Codes Reference of this method for more details.

Error reference

Error CodeError MessageError Description
-3999db: access deniedNo permission to modify permission for a 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

NameRequiredTypeDescription
countRequiredNumberNumber of Ids to reserve.

Call returns

NameRequiredTypeDescription
ReserveIdsResponseOptionalObjectIf the method succeeds it will return a ReserveIdsResponse object.
ErrResponseOptionalObjectIf the method fails, it will return a ErrResponse object.

Error reference

Error CodeError MessageError Description
-3968db: malformed idThe 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;
  },
});

Example

{
  "ids": [
    "J9FJ12j0Usk",
    "J9FJ12j18hJ",
    "J9FJ12j1Mic"
  ],
  "returnValue": true
}

See also

Description

Unlike the find method, the search method call 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 the 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

NameRequiredTypeDescription
queryRequiredObjectQuery for search.
watchOptionalBooleanThe default value 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

NameRequiredTypeDescription
FindResponseOptionalObjectIf the method succeeds, it will return the FindResponse object.
NotificationResponseOptionalObjectIf the method succeeds and the app had set the watch parameter to true, the search will return the NotificationResponse object.
ErrResponseOptionalObjectIf the method fails, it will return a ErrResponse object.

Error reference

Error CodeError MessageError Description
-3987db: invalid filter opAn invalid operation was specified in the filter.
-3978db: invalid queryThere was a syntax error in the query.
-3977db: collations on property do not matchThe collation sequence of a property across different objects do not match.
-3975db: invalid combination of query operationsThe 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',
        },
      ],
    },
  },
  onSuccess: 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

NameRequiredTypeDescription
queryRequiredObjectQuery whose results the app wants to watch.

Call returns

NameRequiredTypeDescription
SuccessResponseOptionalObjectIf DB8 has enough resources to add client into "watch stack" and the method succeeds, it will return the SuccessResponse object.
NotificationResponseOptionalObjectIf DB8 has enough resources to add into "watch stack" and DB8 found some record for the query, it will return a NotificationResponse object.
ErrResponseOptionalObjectIf the method fails, it will return the ErrResponse object.

Error reference

Error CodeError MessageError Description
-3999db: access deniedThe 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;
  },
});

Return example

{
  "returnValue": true,
  "fired": true
}

See also

Object

operation object

The object used to represent a batch operation to run.

{
  "method": string,
  "params": []
}
NameRequiredTypeDescription
methodRequiredStringOperation being requested.
paramsRequiredAny arrayDepends on the type of operation being requested.

SuccessResponse object

Indicates operation success or failure.

// Schema
{
  "returnValue" : boolean
}
// Example
{
  "returnValue": false
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure

ErrResponse object

Standard error response, containing operation success or failure flag, error code and error message.

{
  "returnValue" : boolean,
  "errorCode" : int,
  "errorText" : string
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorCodeRequiredNumberError code from the service. This property is available when the request fails.
errorTextRequiredStringError message from the service. This property is available when the 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
}
NameRequiredTypeDescription
selectOptionalString arrayArray of property names to return
fromRequiredStringName of the kind to retrieve results from
whereOptionalObject arrayArray of clauses to test
orderByOptionalStringOrder results on this property
descOptionalBooleanIf set to true, query results will be returned in a descending order.
incDelOptionalBooleanIf set to 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.
limitOptionalNumberSpecifies the maximum number of results to return (0-500). Default is 500
pageOptionalStringPage key returned by previous query
filterOptionalObject arrayArray of clauses - works only in the search method - identical to WhereClause. Can be used along with where to perform a range search.

IndexClause object

Used in the putKind method 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
}
NameRequiredTypeDescription
nameRequiredStringIndex name
propsRequiredObject arrayArray of properties to index together
incDelOptionalBooleanIf 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.

IndexPropClause object

Defines index property for IndexClause.

{
  "name" : string,
  "collate" : string,
  "default" : any,
  "tokenize" : string,
  "type" : string
}
NameRequiredTypeDescription
collateOptionalStringIndicates the string comparison routine used to order the index.
Must be one of the following:
  • default: Does binary comparison
  • primary: Compares base characters (for example, "a" < "b") without considering accents, case, or tone marks.
  • secondary: Accents in the characters are considered secondary differences (for example, "as" < "às" < "at"). Other differences between letters can also be considered secondary differences, depending on the language. A secondary difference is ignored when there is a primary difference anywhere in the strings.
  • tertiary: Upper and lower case differences in characters are distinguished at the tertiary level (for example, "ao" < "Ao" < "aò"). In addition, a variant of a letter differs from the base form on the tertiary level (such as "A" and "?"). A tertiary difference is ignored when there is a primary or secondary difference anywhere in the strings.
defaultOptionalAnyDefault value to set for this property at insertion time, if not present.
tokenizeOptionalStringIndicates 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:
  • none: Does not tokenize.
  • default: Use the default for the locale (which may strip stop-words). Stop-words are common words that are stripped for purposes of indexing, i.e., "the", "a", "an", "is", etc.
  • all: Tokenizes all words.
typeRequiredStringsingle or multi. Single property or multiple properties.

RevSetClause object

Defines a revision set— the 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.

{
  "name" : string,
  "props" : RevSetPropClause array
}
NameRequiredTypeDescription
nameRequiredStringName of the revision set (unique to this kind).
propRequiredObject arrayArray of properties to include in revision set.

PutResponse object

Indicates success of the operation and returns id and rev fields for each object.

{
  "returnValue" : boolean,
  "results" : PutResult
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
resultsRequiredObject arrayArray of objects containing the id and rev of each object that was put.

PutResult object

Contains id and rev fields in PutResponse for JSON data object.

{
  "id" : any,
  "rev" : any
}
NameRequiredTypeDescription
idRequiredAnyID of the object that was put.
revRequiredAnyObject'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.

CountResponse object

The number of objects affected by the operation.

{
  "returnValue" : boolean,
  "count" : int
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
countRequiredNumberNumber of objects affected by the operation.

FindResponse object

Response to a find objects operation.

{
  "returnValue" : boolean,
  "results" : any,
  "count" : int,
  "next" : string
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
resultsRequiredAnyArray of db8 kind data objects. What is returned depends on the query and what is stored.
countOptionalNumberNumber of results that would have been returned if a limit had not been specified.
nextOptionalStringKey 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 method.

{
  "returnValue" : boolean,
  "fired" : boolean
}
NameRequiredTypeDescription
returnValueOptionalBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
firedRequiredBooleanChange notification flag

GetResponse object

Parameters for getting objects operation response.

{
  "returnValue" : boolean,
  "result" : any
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
resultRequiredObject arrayReturns an array of stored db8 data objects.

BatchResponse object

Response to batch operation.

{
  "returnValue" : boolean,
  "responses" : any array
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
responsesRequiredArrayArray of responses for each of the operations in the batch.

BatchOperation object

Method and params for batch operation.

{
  "method" : string,
  "params" : any
}
NameRequiredTypeDescription
methodRequiredStringDatabase operation to perform.
Allowed values are:
  • del
  • find
  • get
  • merge
  • put
paramsRequiredStringList of parameters for the database operation.

ReserveIdsResponse object

Contains operation success or failure flag and the array of reserved db8 IDs returned from reserveIds method.

{
  "returnValue" : boolean,
  "ids" : string array
}
NameRequiredTypeDescription
returnValueRequiredBooleanFlag that indicates success/failure of the request.
  • true: Success
  • false: Failure
idsOptionalString arrayArray of reserved IDs

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"
}
NameRequiredTypeDescription
propRequiredStringName of property to test.
opRequiredStringTest 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.
valRequiredAnyValue to test against.
collateOptionalStringIndicates 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"
}
NameRequiredTypeDescription
propRequiredStringName of property to test.
opRequiredStringTest 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.
valRequiredAnyValue to test against.
collateOptionalStringIndicates the string comparison routine used to order the results. See the collate field in the IndexPropClause data structure for more information.

RevSetPropClause object

A property in a RevSetClause.

{
  "name" : string,
}
NameRequiredTypeDescription
nameRequiredStringName of property to include in revision set.
No Headings