Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AGCCloudDBZone

en

An object of a Cloud DB zone indicates a Cloud DB storage zone. You can use the methods provided by this class to add, delete, modify, and query data in the Cloud DB zone and perform transactions to manage device-cloud data.

zh

一个Cloud DB zone对象表示一个Cloud DB 的存储区域,通过该类提供的方法实现对 Cloud DB zone 中数据的增、删、改、查和事务等操作,实现端云数据的管理。

Hierarchy

Index

Constructors

constructor

Properties

Private cls_CloudDBZoneHelper

cls_CloudDBZoneHelper: string = "org/cocos2dx/javascript/service/db/CloudDBZoneHelper"

zoneId

zoneId: string

Methods

delete

  • en

    Developers can invoke this method to delete a group of Cloud DB zone objects whose primary key values are the same as those of the input object list in batches. The deletion operation focuses only on whether the primary key of the objects is consistent, regardless of whether other attributes of the object match the stored data. The delete operation is atomic. That is, the input object list is either all deleted successfully or all fails to be deleted. Developers can invoke this method to delete object data only when Cloud DB zone is opened. Otherwise, deleting object data may fail.

    zh

    开发者调用此方法批量删除Cloud DB zone中与传入对象列表主键值相同的一组对象。删除操作只关注对象的主键是否一致,不考虑对象其他属性和存储的数据是否匹配。删除操作是原子的,即传入对象列表要么全部成功删除,要么全部失败。仅当Cloud DB zone为打开状态时,才允许调用此方法删除对象数据,否则可能导致删除失败。

    Parameters

    • queryIdOrObjs: AGCCloudDBZoneQuery | any[]

      A AGCCloudDBZoneQuery object, which indicates the query condition. Or list of CloudDBZoneObject to be deleted.

    • Default value policy: QueryPolicy = QueryPolicy.POLICY_QUERY_FROM_CLOUD_ONLY

      Query policy, which specifies the data source to be queried. Only used by AGCCloudDBZoneQuery.

    Returns void

deleteSync

  • en

    Developers can invoke this method to delete a group of Cloud DB zone objects whose primary key values are the same as those of the input object list in batches. The deletion operation focuses only on whether the primary key of the objects is consistent, regardless of whether other attributes of the object match the stored data. The delete operation is atomic. That is, the input object list is either all deleted successfully or all fails to be deleted. Developers can invoke this method to delete object data only when Cloud DB zone is opened. Otherwise, deleting object data may fail.

    zh

    开发者调用此方法批量删除 Cloud DB zone 中与传入对象列表主键值相同的一组对象。删除操作只关注对象的主键是否一致,不考虑对象其他属性和存储的数据是否匹配。删除操作是原子的,即传入对象列表要么全部成功删除,要么全部失败。仅当 Cloud DB zone 为打开状态时,才允许调用此方法删除对象数据,否则可能导致删除失败。

    Parameters

    • queryIdOrObjs: AGCCloudDBZoneQuery | any[]

      A AGCCloudDBZoneQuery object, which indicates the query condition. Or list of CloudDBZoneObject to be deleted.

    • Default value policy: QueryPolicy = QueryPolicy.POLICY_QUERY_FROM_CLOUD_ONLY

      Query policy, which specifies the data source to be queried. Only used by AGCCloudDBZoneQuery.

    Returns number

    The number of objects that are successfully deleted.

getConfig

  • en

    Developers can invoke this method to obtain the current Cloud DB zone configuration information, including the Cloud DB zone name, synchronization attributes, and access attributes.

    zh

    开发者可调用此方法获取当前 Cloud DB zone 的配置信息,包括 Cloud DB zone 名称、数据同步属性和访问属性等。

    Returns AGCCloudDBZoneConfig

    AGCCloudDBZoneConfig instance

insert

  • insert(objs: any[], typeName: string): void
  • en

    Developers can invoke this method to write an object to the current Cloud DB zone. If objects with the same primary key exist in Cloud DB zone, update the existing object data in Cloud DB zone. Otherwise, insert a new object. Comply with the following rules when invoking this method: Developers can invoke this method to write object data only when Cloud DB zone is opened. Otherwise, the object data may fail to be written. The data size of each object must be less than or equal to 2 MB. Otherwise, the object data may fail to be written. The data size of all objects in the list must be less than or equal to 2 MB only when the data synchronization mode is cache and the data persistency attribute is non-persistent.

    zh

    开发者调用此方法将一组对象批量写入到当前 Cloud DB zone。写入操作是原子的,即传入对象列表要么全部成功写入,要么全部失败。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法写入对象数据,否则可能导致写入失败。 列表中每个对象的数据大小应小于等于 2MB,否则会导致写入失败。 仅在 “数据同步模式” 为 “缓存模式” 且 “数据持久化属性” 为 “非持久化” 时,列表中所有对象的数据总大小应小于等于 2MB,否则会导致写入失败。

    Parameters

    • objs: any[]

      Object list data to be written.

    • typeName: string

      Object Type Name

    Returns void

insertSync

  • insertSync(objs: any[], typeName: string): number
  • en

    Developers can invoke this method to write an object to the current Cloud DB zone. If objects with the same primary key exist in Cloud DB zone, update the existing object data in Cloud DB zone. Otherwise, insert a new object. Comply with the following rules when invoking this method: Developers can invoke this method to write object data only when Cloud DB zone is opened. Otherwise, the object data may fail to be written. The data size of each object must be less than or equal to 2 MB. Otherwise, the object data may fail to be written. The data size of all objects in the list must be less than or equal to 2 MB only when the data synchronization mode is cache and the data persistency attribute is non-persistent.

    zh

    开发者调用此方法将一组对象批量写入到当前Cloud DB zone。写入操作是原子的,即传入对象列表要么全部成功写入,要么全部失败。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法写入对象数据,否则可能导致写入失败。 列表中每个对象的数据大小应小于等于 2MB,否则会导致写入失败。 仅在 “数据同步模式” 为 “缓存模式” 且 “数据持久化属性” 为 “非持久化” 时,列表中所有对象的数据总大小应小于等于 2MB,否则会导致写入失败。

    Parameters

    • objs: any[]

      Object list data to be written.

    • typeName: string

      Object Type Name

    Returns number

    The number of objects that are successfully written.

query

  • en

    Developers can invoke this method to query object data that meets specific conditions from the Cloud DB zone and encapsulates the query result set into a CloudDBZoneSnapshot. Comply with the following rules when invoking this method: Developers can invoke this method to query object data only when Cloud DB zone is opened. Otherwise, the query may fail. When querying data from the cloud, ensure that the size of each query result is less than or equal to 5 MB. Otherwise, the query fails.

    zh

    开发者调用此方法从 Cloud DB zone 中查询满足特定条件的对象数据,并将查询到的结果集封装到一个 CloudDBZoneSnapshot 中。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法查询对象数据,否则可能导致查询失败。 从云侧查询数据时,每次查询结果的数据大小应小于等于 5MB,否则会导致查询失败。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    • policy: QueryPolicy

      Query policy, which specifies the data source to be queried.

    Returns void

queryAverage

  • en

    Developers can invoke this method to query Cloud DB zone object data that meets specified conditions and return the average value of specified fields. This method can be invoked to query the average value of specified fields only when Cloud DB zone is opened. Otherwise, the query may fail.

    zh

    开发者调用此方法从 Cloud DB zone 中查找满足特定条件的对象数据,返回指定字段的平均值。 仅当 Cloud DB zone 为打开状态时,才允许调用此方法查询指定字段的平均值,否则可能导致查询失败。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    • fieldName: string

      Specifies the name of the fields whose average value needs to be calculated in the query object. The data type of a specified field can only be one of the following: Short, Integer, Long, Float, and Double.

    • policy: QueryPolicy

      Query policy, which specifies the data source to be queried.

    Returns void

queryAverageSync

  • en

    Developers can invoke this method to query Cloud DB zone object data that meets specified conditions and return the average value of specified fields. This method can be invoked to query the average value of specified fields only when Cloud DB zone is opened. Otherwise, the query may fail.

    zh

    开发者调用此方法从 Cloud DB zone 中查找满足特定条件的对象数据,返回指定字段的平均值。 仅当 Cloud DB zone 为打开状态时,才允许调用此方法查询指定字段的平均值,否则可能导致查询失败。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    • fieldName: string

      Specifies the name of the fields whose average value needs to be calculated in the query object. The data type of a specified field can only be one of the following: Short, Integer, Long, Float, and Double.

    • policy: QueryPolicy

      Query policy, which specifies the data source to be queried.

    Returns number

    average

querySync

  • en

    Developers can invoke this method to query object data that meets specific conditions from the Cloud DB zone and encapsulates the query result set into a CloudDBZoneSnapshot. Comply with the following rules when invoking this method: Developers can invoke this method to query object data only when Cloud DB zone is opened. Otherwise, the query may fail. When querying data from the cloud, ensure that the size of each query result is less than or equal to 5 MB. Otherwise, the query fails.

    zh

    开发者调用此方法从 Cloud DB zone 中查询满足特定条件的对象数据,并将查询到的结果集封装到一个 CloudDBZoneSnapshot 中。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法查询对象数据,否则可能导致查询失败。 从云侧查询数据时,每次查询结果的数据大小应小于等于 5MB,否则会导致查询失败。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    • policy: QueryPolicy

      Query policy, which specifies the data source to be queried.

    Returns AGCCloudDBObject[]

    Query result list

queryUnsynced

  • en

    Developers can invoke this method to query all Cloud DB object data that meets specified conditions but has not been synchronized to the cloud, and encapsulates the query results into a CloudDBZoneSnapshot. Comply with the following rules when invoking this method: Developers can invoke this method to query object data that is not synchronized to the cloud only when Cloud DB zone is opened. Otherwise, the query may fail. Developers can invoke this method to obtain the object data that is not synchronized to the cloud only when the data synchronization mode is cache mode.

    zh

    开发者调用此方法从Cloud DB中查询所有满足指定条件,但尚未同步到云端的对象数据,并将查询到的结果集封装到一个 CloudDBZoneSnapshot 中。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法查询本地未同步到云端的对象数据,否则可能导致查询失败。 仅在数据同步模式为缓存模式时,调用该方法才会获取到本地未同步到云端的对象数据。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    Returns void

queryUnsyncedSync

  • en

    Developers can invoke this method to query all Cloud DB object data that meets specified conditions but has not been synchronized to the cloud, and encapsulates the query results into a CloudDBZoneSnapshot. Comply with the following rules when invoking this method: Developers can invoke this method to query object data that is not synchronized to the cloud only when Cloud DB zone is opened. Otherwise, the query may fail. Developers can invoke this method to obtain the object data that is not synchronized to the cloud only when the data synchronization mode is cache mode.

    zh

    开发者调用此方法从 Cloud DB 中查询所有满足指定条件,但尚未同步到云端的对象数据,并将查询到的结果集封装到一个 CloudDBZoneSnapshot 中。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法查询本地未同步到云端的对象数据,否则可能导致查询失败。 仅在数据同步模式为缓存模式时,调用该方法才会获取到本地未同步到云端的对象数据。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    Returns AGCCloudDBObject[]

    Query result list

remove

  • remove(subscribeId: string): void
  • en

    This method is used to deregister snapshot listener. If not deregistered, the snapshot listener always takes effect. That is, when the snapshot changes, the system continuously notifies you and calls the on('subscribe', data => {}, node) method. In addition, you cannot close Cloud DB zone.

    zh

    开发者调用此方法注销快照侦听。如果未注销快照侦听,快照侦听将会一直生效,即快照发生任何变化都会持续的通知开发者并调用开发者的 on('subscribe', data => {}, node) 方法,且开发者将会无法关闭 Cloud DB zone。

    Parameters

    • subscribeId: string

      subscribe id

    Returns void

subscribe

  • en

    Developers can invoke this method to register a listener for a specified object data. When the data of the object that is listened on is changed, the registered OnSnapshotListener callback is triggered. After a snapshot listener is registered, the snapshot listener takes effect after a certain period of time (several seconds to dozens of seconds). Therefore, a snapshot before the listener takes effect is not sent to the device. After the listener takes effect, the device can receive the snapshot. If the size of the snapshot exceeds 5 MB or the number of data records contained in the snapshot exceeds 1000, the snapshot cannot be sent to the device. Comply with the following rules when invoking this method: Developers can invoke this method to register a listener only when Cloud DB zone is opened. Otherwise, the listener may fail to be registered. Developers can invoke this method to register a listener only when the Cloud DB zone synchronization mode is cache mode.

    zh

    开发者调用此方法注册一个对特定对象数据的侦听,当侦听的对象数据发生变化,触发注册的 OnSnapshotListener 回调。注册快照侦听后,快照侦听需要一定的时间(几秒到十几秒不等)才会生效,因此,在侦听生效前的快照不会推送到端侧,待侦听生效后,端侧可正常收到快照;当快照的大小超过 5MB 或者快照包含的数据条数超过 1000 条时,快照将无法推送至端侧。 构造查询条件时,当前仅支持等值订阅,即仅支持使用 equalTo() 方法,且查询条件中最少包含一个字段,最多包含 5 个字段,多个查询条件之间采用 运算。 调用本方法需要遵循以下约束: 仅当 Cloud DB zone 为打开状态时,才允许调用此方法注册侦听,否则可能导致注册侦听失败。 仅当 Cloud DB zone 的同步属性为缓存模式时,开发者才允许调用此方法注册侦听。

    Parameters

    • query: AGCCloudDBZoneQuery

      A AGCCloudDBZoneQuery object, which indicates the query condition. Only the equal-value subscription, that is, the equalTo() method can be used to construct query conditions. The query conditions must contain at least one field and at most five fields. The AND operation is used between multiple query conditions.

    • subscribeId: string

      subscribe id

    • policy: QueryPolicy

      A AGCCloudDBZoneQuery object, which indicates the query condition.

    Returns void

Static callStaticMethod

  • callStaticMethod(...args: (number | boolean | string)[]): any

Generated using TypeDoc