提交 414c4bc1 编写于 作者: A annie_wangli

update docs

Signed-off-by: Nannie_wangli <annie.wangli@huawei.com>
上级 5ee9491c
...@@ -7,5 +7,9 @@ ...@@ -7,5 +7,9 @@
- [RDB Overview](database-relational-overview.md) - [RDB Overview](database-relational-overview.md)
- [RDB Development](database-relational-guidelines.md) - [RDB Development](database-relational-guidelines.md)
- Lightweight Data Store - Lightweight Data Store
- [Lightweight Data Store Overview](database-preference-overview.md) - [Lightweight Data Store Overview](database-distributedobject-overview.md)
- [Lightweight Data Store Development](database-preference-guidelines.md) - [Lightweight Data Store Development](database-distributedobject-guidelines.md)
\ No newline at end of file
\ No newline at end of file
# RDB Development<a name="EN-US_TOPIC_0000001185510898"></a> # RDB Development
## When to Use<a name="section3905444123020"></a> ## When to Use
On the basis of the SQLite database, the RDB allows you to operate data with or without native SQL statements. An RDB is also called RDB store. On the basis of the SQLite database, the relational database (RDB) allows you to operate data with or without native SQL statements. In OpenHarmony, an RDB is also called RDB store.
## Available APIs<a name="section5504175713016"></a>
## Available APIs
**Creating and Deleting an RDB Store** **Creating and Deleting an RDB Store**
The following table describes APIs available for creating and deleting an RDB store. The following table describes the APIs available for creating and deleting an RDB store.
**Table 1** APIs for creating and deleting an RDB store
<a name="table191861518153620"></a>
<table><thead align="left"><tr id="row14232318163610"><th class="cellrowborder" valign="top" width="16.650000000000002%" id="mcps1.2.4.1.1"><p id="p17444101665110"><a name="p17444101665110"></a><a name="p17444101665110"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="30.61%" id="mcps1.2.4.1.2"><p id="p182321618163611"><a name="p182321618163611"></a><a name="p182321618163611"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="52.739999999999995%" id="mcps1.2.4.1.3"><p id="p1623211815366"><a name="p1623211815366"></a><a name="p1623211815366"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row16783162014173"><td class="cellrowborder" valign="top" width="16.650000000000002%" headers="mcps1.2.4.1.1 "><p id="p17783122019176"><a name="p17783122019176"></a><a name="p17783122019176"></a>dataRdb</p>
</td>
<td class="cellrowborder" valign="top" width="30.61%" headers="mcps1.2.4.1.2 "><p id="p231111599237"><a name="p231111599237"></a><a name="p231111599237"></a>getRdbStore(config: StoreConfig, version: number, callback: AsyncCallback&lt;RdbStore&gt;): void</p>
</td>
<td class="cellrowborder" valign="top" width="52.739999999999995%" headers="mcps1.2.4.1.3 "><p id="p9186112481614"><a name="p9186112481614"></a><a name="p9186112481614"></a>Obtains an RDB store. You can set parameters for the RDB store based on service requirements, call APIs to perform data operations, and use a callback to return the result.</p>
<a name="ul20498114912320"></a><a name="ul20498114912320"></a><ul id="ul20498114912320"><li><strong id="b4112115595818"><a name="b4112115595818"></a><a name="b4112115595818"></a>config</strong>: configuration of the RDB store.</li><li><strong id="b11397121135919"><a name="b11397121135919"></a><a name="b11397121135919"></a>version</strong>: version of the RDB store.</li><li><strong id="b43570718591"><a name="b43570718591"></a><a name="b43570718591"></a>callback</strong>: callback invoked to return the RDB store.</li></ul>
</td>
</tr>
<tr id="row32321018143616"><td class="cellrowborder" valign="top" width="16.650000000000002%" headers="mcps1.2.4.1.1 "><p id="p12399202916814"><a name="p12399202916814"></a><a name="p12399202916814"></a>dataRdb</p>
</td>
<td class="cellrowborder" valign="top" width="30.61%" headers="mcps1.2.4.1.2 "><p id="p3501131011457"><a name="p3501131011457"></a><a name="p3501131011457"></a>getRdbStore(config: StoreConfig, version: number): Promise&lt;RdbStore&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="52.739999999999995%" headers="mcps1.2.4.1.3 "><p id="p17526162133220"><a name="p17526162133220"></a><a name="p17526162133220"></a>Obtains an RDB store. You can set parameters for the RDB store based on service requirements, call APIs to perform data operations, and use a promise to return the result.</p>
<a name="ul19719610863"></a><a name="ul19719610863"></a><ul id="ul19719610863"><li><strong id="b153861822027"><a name="b153861822027"></a><a name="b153861822027"></a>config</strong>: configuration of the RDB store.</li><li><strong id="b175492306216"><a name="b175492306216"></a><a name="b175492306216"></a>version</strong>: version of the RDB store.</li></ul>
</td>
</tr>
<tr id="row1423210186365"><td class="cellrowborder" valign="top" width="16.650000000000002%" headers="mcps1.2.4.1.1 "><p id="p94441216175111"><a name="p94441216175111"></a><a name="p94441216175111"></a>dataRdb</p>
</td>
<td class="cellrowborder" valign="top" width="30.61%" headers="mcps1.2.4.1.2 "><p id="p1056516197468"><a name="p1056516197468"></a><a name="p1056516197468"></a>deleteRdbStore(name: string, callback: AsyncCallback&lt;void&gt;): void</p>
</td>
<td class="cellrowborder" valign="top" width="52.739999999999995%" headers="mcps1.2.4.1.3 "><p id="p761845132510"><a name="p761845132510"></a><a name="p761845132510"></a>Deletes an RDB store. This method uses a callback to return the result.</p>
<a name="ul11527402717"></a><a name="ul11527402717"></a><ul id="ul11527402717"><li><strong id="b152695571624"><a name="b152695571624"></a><a name="b152695571624"></a>name</strong>: name of the RDB store to delete.</li><li><strong id="b11959131911316"><a name="b11959131911316"></a><a name="b11959131911316"></a>callback</strong>: callback invoked to return the result. If the RDB store is deleted, <strong id="b717583515112554"><a name="b717583515112554"></a><a name="b717583515112554"></a>true</strong> will be returned. Otherwise, <strong id="b1492094045112554"><a name="b1492094045112554"></a><a name="b1492094045112554"></a>false</strong> will be returned.</li></ul>
</td>
</tr>
<tr id="row923319186367"><td class="cellrowborder" valign="top" width="16.650000000000002%" headers="mcps1.2.4.1.1 "><p id="p66511731173510"><a name="p66511731173510"></a><a name="p66511731173510"></a>dataRdb</p>
</td>
<td class="cellrowborder" valign="top" width="30.61%" headers="mcps1.2.4.1.2 "><p id="p29801620134717"><a name="p29801620134717"></a><a name="p29801620134717"></a>deleteRdbStore(name: string): Promise&lt;void&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="52.739999999999995%" headers="mcps1.2.4.1.3 "><p id="p1112512307296"><a name="p1112512307296"></a><a name="p1112512307296"></a>Deletes an RDB store. This method uses a promise to return the result.</p>
<a name="ul114112033"></a><a name="ul114112033"></a><ul id="ul114112033"><li><strong id="b8147125819315"><a name="b8147125819315"></a><a name="b8147125819315"></a>name</strong>: name of the RDB store to delete.</li></ul>
</td>
</tr>
</tbody>
</table>
**Managing Data in an RDB Store** **Table 1** APIs for creating and deleting an RDB store
| Class| API| Description|
| -------- | -------- | -------- |
| dataRdb | getRdbStore(config:&nbsp;StoreConfig,&nbsp;version:&nbsp;number,&nbsp;callback:&nbsp;AsyncCallback&lt;RdbStore&gt;):&nbsp;void | Obtains an RDB store. This method uses a callback to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.<br>-&nbsp;**config**: configuration of the RDB store.<br>-&nbsp;**version**: RDB version.<br>-&nbsp;**callback**: callback invoked to return the RDB store obtained.|
| dataRdb | getRdbStore(config:&nbsp;StoreConfig,&nbsp;version:&nbsp;number):&nbsp;Promise&lt;RdbStore&gt; | Obtains an RDB store. This method uses a promise to return the result. You can set parameters for the RDB store based on service requirements, and then call APIs to perform data operations.<br>-&nbsp;**config**: configuration of the RDB store.<br>-&nbsp;**version**: RDB version.|
| dataRdb | deleteRdbStore(name:&nbsp;string,&nbsp;callback:&nbsp;AsyncCallback&lt;void&gt;):&nbsp;void | Deletes an RDB store. This method uses a callback to return the result. <br>-&nbsp;**name**: RDB store to delete.<br>-&nbsp;**callback**: callback invoked to return the result. If the RDB store is deleted, **true** will be returned. Otherwise, **false** will be returned.|
| dataRdb | deleteRdbStore(name:&nbsp;string):&nbsp;Promise&lt;void&gt; | Deletes an RDB store. This method uses a promise to return the result.<br>-&nbsp;**name**: RDB store to delete.|
The RDB provides APIs for inserting, deleting, modifying, and querying data in the local RDB store. **Managing Data in an RDB Store**
- **Inserting data**
The RDB provides methods for inserting data through **ValuesBucket** in a data table. If the data is inserted successfully, the row number of the data inserted is returned; otherwise, **-1** is returned.
**Table 2** APIs for inserting data to a data table
<a name="table96811457164612"></a>
<table><thead align="left"><tr id="row1971245734616"><th class="cellrowborder" valign="top" width="11.53%" id="mcps1.2.4.1.1"><p id="p102415083812"><a name="p102415083812"></a><a name="p102415083812"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="42.230000000000004%" id="mcps1.2.4.1.2"><p id="p371235717461"><a name="p371235717461"></a><a name="p371235717461"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="46.239999999999995%" id="mcps1.2.4.1.3"><p id="p471215713468"><a name="p471215713468"></a><a name="p471215713468"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row14918412104220"><td class="cellrowborder" valign="top" width="11.53%" headers="mcps1.2.4.1.1 "><p id="p691914127421"><a name="p691914127421"></a><a name="p691914127421"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="42.230000000000004%" headers="mcps1.2.4.1.2 "><p id="p12888149165312"><a name="p12888149165312"></a><a name="p12888149165312"></a>insert(name: string, values: ValuesBucket, callback: AsyncCallback&lt;number&gt;):void</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p891981214423"><a name="p891981214423"></a><a name="p891981214423"></a>Inserts a row of data into a table. This method uses a callback to return the result.</p>
<a name="ul929362324319"></a><a name="ul929362324319"></a><ul id="ul929362324319"><li><strong id="b791810215118"><a name="b791810215118"></a><a name="b791810215118"></a>name</strong>: name of the target table.</li><li><strong id="b1168133481113"><a name="b1168133481113"></a><a name="b1168133481113"></a>values</strong>: data to be inserted into the table.</li><li><strong id="b153601828111218"><a name="b153601828111218"></a><a name="b153601828111218"></a>callback</strong>: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, <strong id="b1062976631112554"><a name="b1062976631112554"></a><a name="b1062976631112554"></a>-1</strong> will be returned.</li></ul>
</td>
</tr>
<tr id="row17129579467"><td class="cellrowborder" valign="top" width="11.53%" headers="mcps1.2.4.1.1 "><p id="p6240010381"><a name="p6240010381"></a><a name="p6240010381"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="42.230000000000004%" headers="mcps1.2.4.1.2 "><p id="p18352838115114"><a name="p18352838115114"></a><a name="p18352838115114"></a>insert(name: string, values: ValuesBucket): Promise&lt;number&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p579311300812"><a name="p579311300812"></a><a name="p579311300812"></a>Inserts a row of data into a table. This method uses a promise to return the result.</p>
<a name="ul121533410439"></a><a name="ul121533410439"></a><ul id="ul121533410439"><li><strong id="b928413422120"><a name="b928413422120"></a><a name="b928413422120"></a>name</strong>: name of the target table.</li><li><strong id="b17334499123"><a name="b17334499123"></a><a name="b17334499123"></a>values</strong>: data to be inserted into the table.</li></ul>
</td>
</tr>
</tbody>
</table>
- **Updating data**
Call the **update\(\)** method to pass the new data and specify the update conditions by using **RdbPredicates**. If the data is successfully updated, the row number of the updated data is returned; otherwise, **0** is returned.
**Table 3** APIs for updating data
<a name="table183714445119"></a>
<table><thead align="left"><tr id="row766194475113"><th class="cellrowborder" valign="top" width="8.92%" id="mcps1.2.4.1.1"><p id="p987519262464"><a name="p987519262464"></a><a name="p987519262464"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="45.050000000000004%" id="mcps1.2.4.1.2"><p id="p1766144165119"><a name="p1766144165119"></a><a name="p1766144165119"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="46.03%" id="mcps1.2.4.1.3"><p id="p16663445516"><a name="p16663445516"></a><a name="p16663445516"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1597713174814"><td class="cellrowborder" valign="top" width="8.92%" headers="mcps1.2.4.1.1 "><p id="p14978183124810"><a name="p14978183124810"></a><a name="p14978183124810"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="45.050000000000004%" headers="mcps1.2.4.1.2 "><p id="p17502226105513"><a name="p17502226105513"></a><a name="p17502226105513"></a>update(values: ValuesBucket, rdbPredicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void</p>
</td>
<td class="cellrowborder" valign="top" width="46.03%" headers="mcps1.2.4.1.3 "><p id="p173581429117"><a name="p173581429117"></a><a name="p173581429117"></a>Updates the data that meets the conditions specified by the <strong id="b656572122112554"><a name="b656572122112554"></a><a name="b656572122112554"></a>RdbPredicates</strong> object. This method uses a callback to return the result.</p>
<a name="ul192831157114818"></a><a name="ul192831157114818"></a><ul id="ul192831157114818"><li><strong id="b174257709112554"><a name="b174257709112554"></a><a name="b174257709112554"></a>values</strong>: data to update, which is stored in <strong id="b721764115206"><a name="b721764115206"></a><a name="b721764115206"></a>ValuesBucket</strong>.</li><li><strong id="b09125491559"><a name="b09125491559"></a><a name="b09125491559"></a>rdbPredicates</strong>: conditions for updating data.</li><li><strong id="b10866112471917"><a name="b10866112471917"></a><a name="b10866112471917"></a>callback</strong>: callback invoked to return the number of rows updated.</li></ul>
</td>
</tr>
<tr id="row9207612172712"><td class="cellrowborder" valign="top" width="8.92%" headers="mcps1.2.4.1.1 "><p id="p287617260466"><a name="p287617260466"></a><a name="p287617260466"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="45.050000000000004%" headers="mcps1.2.4.1.2 "><p id="p19559457195711"><a name="p19559457195711"></a><a name="p19559457195711"></a>update(values: ValuesBucket, rdbPredicates: RdbPredicates): Promise</p>
</td>
<td class="cellrowborder" valign="top" width="46.03%" headers="mcps1.2.4.1.3 "><p id="p102077125277"><a name="p102077125277"></a><a name="p102077125277"></a>Updates the data that meets the conditions specified by the <strong id="b11262847102416"><a name="b11262847102416"></a><a name="b11262847102416"></a>RdbPredicates</strong> object. This method uses a promise to return the result.</p>
<a name="ul3397556155017"></a><a name="ul3397556155017"></a><ul id="ul3397556155017"><li><strong id="b694170152510"><a name="b694170152510"></a><a name="b694170152510"></a>values</strong>: data to update, which is stored in <strong id="b3949012512"><a name="b3949012512"></a><a name="b3949012512"></a>ValuesBucket</strong>.</li><li><strong id="b1992219615"><a name="b1992219615"></a><a name="b1992219615"></a>rdbPredicates</strong>: conditions for updating data.</li></ul>
</td>
</tr>
</tbody>
</table>
- **Deleting data**
Call the **delete\(\)** method to delete data meeting the conditions specified by **RdbPredicates**. If the data is deleted, the row number of the deleted data is returned; otherwise, **0** is returned.
**Table 4** APIs for deleting data
<a name="table12163622913"></a>
<table><thead align="left"><tr id="row111891027912"><th class="cellrowborder" valign="top" width="10.02%" id="mcps1.2.4.1.1"><p id="p3130348174917"><a name="p3130348174917"></a><a name="p3130348174917"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="32.440000000000005%" id="mcps1.2.4.1.2"><p id="p16189172593"><a name="p16189172593"></a><a name="p16189172593"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="57.54%" id="mcps1.2.4.1.3"><p id="p191899219916"><a name="p191899219916"></a><a name="p191899219916"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row23075814814"><td class="cellrowborder" valign="top" width="10.02%" headers="mcps1.2.4.1.1 "><p id="p181301484494"><a name="p181301484494"></a><a name="p181301484494"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="32.440000000000005%" headers="mcps1.2.4.1.2 "><p id="p8308781086"><a name="p8308781086"></a><a name="p8308781086"></a>delete(rdbPredicates: RdbPredicates, callback: AsyncCallback&lt;number&gt;):void</p>
</td>
<td class="cellrowborder" valign="top" width="57.54%" headers="mcps1.2.4.1.3 "><p id="p1746563812810"><a name="p1746563812810"></a><a name="p1746563812810"></a>Deletes data based on the conditions specified by <strong id="b25823275112554"><a name="b25823275112554"></a><a name="b25823275112554"></a>RdbPredicates</strong>. This method uses a callback to return the result.</p>
<a name="ul199371937131312"></a><a name="ul199371937131312"></a><ul id="ul199371937131312"><li><strong id="b9647017192914"><a name="b9647017192914"></a><a name="b9647017192914"></a>rdbPredicates</strong>: conditions for deleting data.</li><li><strong id="b99708313304"><a name="b99708313304"></a><a name="b99708313304"></a>callback</strong>: callback invoked to return the number of rows deleted.</li></ul>
</td>
</tr>
<tr id="row124255515487"><td class="cellrowborder" valign="top" width="10.02%" headers="mcps1.2.4.1.1 "><p id="p1642575144818"><a name="p1642575144818"></a><a name="p1642575144818"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="32.440000000000005%" headers="mcps1.2.4.1.2 "><p id="p194252051194818"><a name="p194252051194818"></a><a name="p194252051194818"></a>delete(rdbPredicates: RdbPredicates): Promise</p>
</td>
<td class="cellrowborder" valign="top" width="57.54%" headers="mcps1.2.4.1.3 "><p id="p124258512483"><a name="p124258512483"></a><a name="p124258512483"></a>Deletes data based on the conditions specified by <strong id="b801327406112554"><a name="b801327406112554"></a><a name="b801327406112554"></a>RdbPredicates</strong>. This method uses a promise to return the result.</p>
<a name="ul0605102031416"></a><a name="ul0605102031416"></a><ul id="ul0605102031416"><li><strong id="b220745383116"><a name="b220745383116"></a><a name="b220745383116"></a>rdbPredicates</strong>: conditions for deleting data.</li></ul>
</td>
</tr>
</tbody>
</table>
- **Querying data**
You can query data in the RDB in either of the following ways:
- Call the **query** method to query data based on the predicates, without passing any SQL statement.
- Run the native SQL statement.
**Table 5** APIs for querying data
<a name="table1431902161617"></a>
<table><thead align="left"><tr id="row2350122161613"><th class="cellrowborder" valign="top" width="12.46%" id="mcps1.2.4.1.1"><p id="p114619172530"><a name="p114619172530"></a><a name="p114619172530"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="40.97%" id="mcps1.2.4.1.2"><p id="p163501211165"><a name="p163501211165"></a><a name="p163501211165"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="46.57%" id="mcps1.2.4.1.3"><p id="p1635118221618"><a name="p1635118221618"></a><a name="p1635118221618"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row1351629160"><td class="cellrowborder" valign="top" width="12.46%" headers="mcps1.2.4.1.1 "><p id="p314691719532"><a name="p314691719532"></a><a name="p314691719532"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="40.97%" headers="mcps1.2.4.1.2 "><p id="p1365120526456"><a name="p1365120526456"></a><a name="p1365120526456"></a>query(rdbPredicates: RdbPredicates, columns: Array, callback: AsyncCallback&lt;ResultSet&gt;): void;</p>
</td>
<td class="cellrowborder" valign="top" width="46.57%" headers="mcps1.2.4.1.3 "><p id="p854321661212"><a name="p854321661212"></a><a name="p854321661212"></a>Queries data in the database based on specified conditions. This method uses a callback to return the result.</p>
<a name="ul8744621511"></a><a name="ul8744621511"></a><ul id="ul8744621511"><li><strong id="b10609165211337"><a name="b10609165211337"></a><a name="b10609165211337"></a>rdbPredicates</strong>: conditions for querying data.</li></ul>
<a name="ul976011905112"></a><a name="ul976011905112"></a><ul id="ul976011905112"><li><strong id="b017915301348"><a name="b017915301348"></a><a name="b017915301348"></a>columns</strong>: columns to query. If this parameter is not specified, the query applies to all columns.</li><li><strong id="b45789585356"><a name="b45789585356"></a><a name="b45789585356"></a>callback</strong>: callback invoked to return the result. If the operation is successful, a <strong id="b575560452112554"><a name="b575560452112554"></a><a name="b575560452112554"></a>ResultSet</strong> object will be returned.</li></ul>
</td>
</tr>
<tr id="row156116124816"><td class="cellrowborder" valign="top" width="12.46%" headers="mcps1.2.4.1.1 "><p id="p66112124816"><a name="p66112124816"></a><a name="p66112124816"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="40.97%" headers="mcps1.2.4.1.2 "><p id="p194111833115618"><a name="p194111833115618"></a><a name="p194111833115618"></a>query(rdbPredicates: RdbPredicates, columns: Array): Promise&lt;ResultSet&gt;;</p>
</td>
<td class="cellrowborder" valign="top" width="46.57%" headers="mcps1.2.4.1.3 "><p id="p3681422175117"><a name="p3681422175117"></a><a name="p3681422175117"></a>Queries data in the database based on specified conditions. This method uses a promise to return the result.</p>
<a name="ul882719171553"></a><a name="ul882719171553"></a><ul id="ul882719171553"><li><strong id="b42961422123414"><a name="b42961422123414"></a><a name="b42961422123414"></a>rdbPredicates</strong>: conditions for querying data.</li></ul>
<a name="ul982714175553"></a><a name="ul982714175553"></a><ul id="ul982714175553"><li><strong id="b1556413233711"><a name="b1556413233711"></a><a name="b1556413233711"></a>columns</strong>: columns to query. If this parameter is not specified, the query applies to all columns.</li></ul>
</td>
</tr>
<tr id="row196741256281"><td class="cellrowborder" valign="top" width="12.46%" headers="mcps1.2.4.1.1 "><p id="p567445132814"><a name="p567445132814"></a><a name="p567445132814"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="40.97%" headers="mcps1.2.4.1.2 "><p id="p66741959283"><a name="p66741959283"></a><a name="p66741959283"></a>querySql(sql: string, bindArgs: Array&lt;ValueType&gt;, callback: AsyncCallback&lt;ResultSet&gt;):void</p>
</td>
<td class="cellrowborder" valign="top" width="46.57%" headers="mcps1.2.4.1.3 "><p id="p767418510287"><a name="p767418510287"></a><a name="p767418510287"></a>Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result.</p>
<a name="ul98232063110"></a><a name="ul98232063110"></a><ul id="ul98232063110"><li><strong id="b161631620174220"><a name="b161631620174220"></a><a name="b161631620174220"></a>sql</strong>: SQL statement.</li></ul>
<a name="ul982192010316"></a><a name="ul982192010316"></a><ul id="ul982192010316"><li><strong id="b125394844210"><a name="b125394844210"></a><a name="b125394844210"></a>bindArgs</strong>: arguments in the SQL statement.</li><li><strong id="b126351142164316"><a name="b126351142164316"></a><a name="b126351142164316"></a>callback</strong>: callback invoked to return the result. If the operation is successful, a <strong id="b1798798407112554"><a name="b1798798407112554"></a><a name="b1798798407112554"></a>ResultSet</strong> object will be returned.</li></ul>
</td>
</tr>
<tr id="row14262191015289"><td class="cellrowborder" valign="top" width="12.46%" headers="mcps1.2.4.1.1 "><p id="p132621010122817"><a name="p132621010122817"></a><a name="p132621010122817"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="40.97%" headers="mcps1.2.4.1.2 "><p id="p5262510122817"><a name="p5262510122817"></a><a name="p5262510122817"></a>querySql(sql: string, bindArgs?: Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt;</p>
</td>
<td class="cellrowborder" valign="top" width="46.57%" headers="mcps1.2.4.1.3 "><p id="p15262131018288"><a name="p15262131018288"></a><a name="p15262131018288"></a>Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result.</p>
<a name="ul265516228313"></a><a name="ul265516228313"></a><ul id="ul265516228313"><li><strong id="b17420163394412"><a name="b17420163394412"></a><a name="b17420163394412"></a>sql</strong>: SQL statement.</li></ul>
<a name="ul36551222123116"></a><a name="ul36551222123116"></a><ul id="ul36551222123116"><li><strong id="b19751173811446"><a name="b19751173811446"></a><a name="b19751173811446"></a>bindArgs</strong>: arguments in the SQL statement.</li></ul>
</td>
</tr>
</tbody>
</table>
The RDB provides APIs for inserting, deleting, updating, and querying data in the local RDB store.
- **Inserting data**
The RDB provides APIs for inserting data through a **ValuesBucket** in a data table. If the data is inserted, the row ID of the data inserted will be returned; otherwise, **-1** will be returned.
**Table 2** APIs for inserting data
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | insert(name:&nbsp;string,&nbsp;values:&nbsp;ValuesBucket,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Inserts a row of data into a table. This method uses a callback to return the result.<br>-&nbsp;**name**: name of the target table.<br>-&nbsp;**values**: data to be inserted into the table.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, the row ID will be returned. Otherwise, **-1** will be returned.|
| RdbStore | insert(name:&nbsp;string,&nbsp;values:&nbsp;ValuesBucket):&nbsp;Promise&lt;number&gt; | Inserts a row of data into a table. This method uses a promise to return the result.<br>-&nbsp;**name**: name of the target table.<br>-&nbsp;**values**: data to be inserted into the table.|
- **Updating data**
Call the **update()** method to pass new data and specify the update conditions by using **RdbPredicates**. If the data is updated, the number of rows of the updated data will be returned; otherwise, **0** will be returned.
**Table 3** APIs for updating data
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | update(values:&nbsp;ValuesBucket,&nbsp;rdbPredicates:&nbsp;RdbPredicates,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**values**: data to update, which is stored in a **ValuesBucket**.<br>-&nbsp;**rdbPredicates**: conditions for updating data.<br>-&nbsp;**callback**: callback invoked to return the number of rows updated.|
| RdbStore | update(values:&nbsp;ValuesBucket,&nbsp;rdbPredicates:&nbsp;RdbPredicates):&nbsp;Promise | Updates data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**values**: data to update, which is stored in a **ValuesBucket**.<br>-&nbsp;**rdbPredicates**: conditions for updating data.|
- **Deleting data**
Call the **delete()** method to delete data meeting the conditions specified by **RdbPredicates**. If the data is deleted, the number of rows of the deleted data will be returned; otherwise, **0** will be returned.
**Table 4** APIs for deleting data
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | delete(rdbPredicates:&nbsp;RdbPredicates,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**rdbPredicates**: conditions for deleting data.<br>-&nbsp;**callback**: callback invoked to return the number of rows deleted.|
| RdbStore | delete(rdbPredicates:&nbsp;RdbPredicates):&nbsp;Promise | Deletes data from the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**rdbPredicates**: conditions for deleting data.|
- **Querying data**
You can query data in an RDB store in either of the following ways:
- Call the **query()** method to query data based on the predicates, without passing any SQL statement.
- Run the native SQL statement.
**Table 5** APIs for querying data
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | query(rdbPredicates:&nbsp;RdbPredicates,&nbsp;columns:&nbsp;Array,&nbsp;callback:&nbsp;AsyncCallback&lt;ResultSet&gt;):&nbsp;void | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a callback to return the result.<br>-&nbsp;**rdbPredicates**: conditions for querying data.<br>-&nbsp;**columns**: columns to query. If this parameter is not specified, the query applies to all columns.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| RdbStore | query(rdbPredicates:&nbsp;RdbPredicates,&nbsp;columns:&nbsp;Array):&nbsp;Promise&lt;ResultSet&gt; | Queries data in the RDB store based on the specified **RdbPredicates** object. This method uses a promise to return the result.<br>-&nbsp;**rdbPredicates**: conditions for querying data.<br>-&nbsp;**columns**: columns to query. If this parameter is not specified, the query applies to all columns.|
| RdbStore | querySql(sql:&nbsp;string,&nbsp;bindArgs:&nbsp;Array&lt;ValueType&gt;,&nbsp;callback:&nbsp;AsyncCallback&lt;ResultSet&gt;):void | Queries data in the RDB store using the specified SQL statement. This method uses a callback to return the result.<br>-&nbsp;**sql**: SQL statement.<br>-&nbsp;**bindArgs**: arguments in the SQL statement.<br>-&nbsp;**callback**: callback invoked to return the result. If the operation is successful, a **ResultSet** object will be returned.|
| RdbStore | querySql(sql:&nbsp;string,&nbsp;bindArgs?:&nbsp;Array&lt;ValueType&gt;):Promise&lt;ResultSet&gt; | Queries data in the RDB store using the specified SQL statement. This method uses a promise to return the result.<br>-&nbsp;**sql**: SQL statement.<br>-&nbsp;**bindArgs**: arguments in the SQL statement.|
**Using Predicates** **Using Predicates**
The RDB provides **RdbPredicates** for you to set database operation conditions. The RDB provides **RdbPredicates** for you to set database operation conditions.
**Table 6** APIs for RDB predicates **Table 6** APIs for using RDB store predicates
<a name="table1431052112351"></a> | Class| API| Description|
<table><thead align="left"><tr id="row1345821123514"><th class="cellrowborder" valign="top" width="13.850000000000001%" id="mcps1.2.4.1.1"><p id="p142295625511"><a name="p142295625511"></a><a name="p142295625511"></a>Class</p> | -------- | -------- | -------- |
</th> | RdbPredicates |inDevices(devices: Array<string>): RdbPredicates | Specifies remote devices on the network with RDB stores to be synchronized.<br>-&nbsp;**devices**: IDs of the remote devices on the network.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
<th class="cellrowborder" valign="top" width="39.910000000000004%" id="mcps1.2.4.1.2"><p id="p1034572111355"><a name="p1034572111355"></a><a name="p1034572111355"></a>API</p> | RdbPredicates |inAllDevices(): RdbPredicates | Connects to all remote devices on the network with RDB stores to be synchronized.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</th> | RdbPredicates | equalTo(field:&nbsp;string,&nbsp;value:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value equal to the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
<th class="cellrowborder" valign="top" width="46.239999999999995%" id="mcps1.2.4.1.3"><p id="p193451621113517"><a name="p193451621113517"></a><a name="p193451621113517"></a>Description</p> | RdbPredicates | notEqualTo(field:&nbsp;string,&nbsp;value:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value not equal to the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</th> | RdbPredicates | beginWrap():&nbsp;RdbPredicates | Adds a left parenthesis to the **RdbPredicates**.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** with a left parenthesis. |
</tr> | RdbPredicates | endWrap():&nbsp;RdbPredicates | Adds a right parenthesis to the **RdbPredicates**.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** with a right parenthesis. |
</thead> | RdbPredicates | or():&nbsp;RdbPredicates | Adds the OR condition to the **RdbPredicates**.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** with the OR condition. |
<tbody><tr id="row434562114350"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p164375497585"><a name="p164375497585"></a><a name="p164375497585"></a>RdbPredicates</p> | RdbPredicates | and():&nbsp;RdbPredicates | Adds the AND condition to the **RdbPredicates**.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** with the AND condition. |
</td> | RdbPredicates | contains(field:&nbsp;string,&nbsp;value:&nbsp;string):&nbsp;RdbPredicats | Sets the **RdbPredicates** to match a string containing the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p1984411183347"><a name="p1984411183347"></a><a name="p1984411183347"></a>equalTo(field: string, value: ValueType): RdbPredicates</p> | RdbPredicates | beginsWith(field:&nbsp;string,&nbsp;value:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match a string that starts with the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
</td> | RdbPredicates | endsWith(field:&nbsp;string,&nbsp;value:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match a string that ends with the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p10345221143519"><a name="p10345221143519"></a><a name="p10345221143519"></a>Sets the <strong id="b438950696112554"><a name="b438950696112554"></a><a name="b438950696112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b749976932112554"><a name="b749976932112554"></a><a name="b749976932112554"></a>ValueType</strong> and value equal to the specified value.</p> | RdbPredicates | isNull(field:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field whose value is null.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
<a name="ul39107814371"></a><a name="ul39107814371"></a><ul id="ul39107814371"><li><strong id="b15195122118513"><a name="b15195122118513"></a><a name="b15195122118513"></a>field</strong>: column name in the database table.</li><li><strong id="b18580195411521"><a name="b18580195411521"></a><a name="b18580195411521"></a>value</strong>: value to match the <strong id="b119217321114"><a name="b119217321114"></a><a name="b119217321114"></a>RdbPredicates</strong>.</li><li><strong id="b82912449110"><a name="b82912449110"></a><a name="b82912449110"></a>RdbPredicates</strong>: <strong id="b20646112018129"><a name="b20646112018129"></a><a name="b20646112018129"></a>RdbPredicates</strong> object that matches the specified field.</li></ul> | RdbPredicates | isNotNull(field:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field whose value is not null.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</td> | RdbPredicates | like(field:&nbsp;string,&nbsp;value:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match a string that is similar to the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
</tr> | RdbPredicates | glob(field:&nbsp;string,&nbsp;value:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the specified string.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified string. |
<tr id="row734514211353"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1221568552"><a name="p1221568552"></a><a name="p1221568552"></a>RdbPredicates</p> | RdbPredicates | between(field:&nbsp;string,&nbsp;low:&nbsp;ValueType,&nbsp;high:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value within the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**low**: minimum value that matches the **RdbPredicates**.<br>-&nbsp;**high**: maximum value that matches the **RdbPredicates**.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</td> | RdbPredicates | notBetween(field:&nbsp;string,&nbsp;low:&nbsp;ValueType,&nbsp;high:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value out of the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**low**: minimum value that matches the **RdbPredicates**.<br>-&nbsp;**high**: maximum value that matches the **RdbPredicates**.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p7639121743518"><a name="p7639121743518"></a><a name="p7639121743518"></a>notEqualTo(field: string, value: ValueType): RdbPredicates</p> | RdbPredicates | greaterThan(field:&nbsp;string,&nbsp;value:&nbsp;ValueType):&nbsp;RdbPredicatesgr | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</td> | RdbPredicates | lessThan(field:&nbsp;string,&nbsp;value:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1634522183511"><a name="p1634522183511"></a><a name="p1634522183511"></a>Sets the <strong id="b1712658660112554"><a name="b1712658660112554"></a><a name="b1712658660112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b726568859112554"><a name="b726568859112554"></a><a name="b726568859112554"></a>ValueType</strong> and value not equal to the specified value.</p> | RdbPredicates | greaterThanOrEqualTo(field:&nbsp;string,&nbsp;value:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value greater than or equal to the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
<a name="ul415220710398"></a><a name="ul415220710398"></a><ul id="ul415220710398"><li><strong id="b066019819910"><a name="b066019819910"></a><a name="b066019819910"></a>field</strong>: column name in the database table.</li><li><strong id="b1810912616128"><a name="b1810912616128"></a><a name="b1810912616128"></a>value</strong>: value to match the <strong id="b1010920661216"><a name="b1010920661216"></a><a name="b1010920661216"></a>RdbPredicates</strong>.</li><li><strong id="b63152431127"><a name="b63152431127"></a><a name="b63152431127"></a>RdbPredicates</strong>: <strong id="b133155430127"><a name="b133155430127"></a><a name="b133155430127"></a>RdbPredicates</strong> object that matches the specified field.</li></ul> | RdbPredicates | lessThanOrEqualTo(field:&nbsp;string,&nbsp;value:&nbsp;ValueType):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **ValueType** and value less than or equal to the specified value.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: value specified.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</td> | RdbPredicates | orderByAsc(field:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in ascending order.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that sorts the values in ascending order. |
</tr> | RdbPredicates | orderByDesc(field:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the column with values sorted in descending order.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that sorts the values in descending order. |
<tr id="row634552123510"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1523656185515"><a name="p1523656185515"></a><a name="p1523656185515"></a>RdbPredicates</p> | RdbPredicates | distinct():&nbsp;RdbPredicates | Sets the **RdbPredicates** to filter out duplicate records.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that can filter out duplicate records. |
</td> | RdbPredicates | limitAs(value:&nbsp;number):&nbsp;RdbPredicates | Sets the **RdbPredicates** to specify the maximum number of records.<br>-&nbsp;**value**: maximum number of records.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that can be used to set the maximum number of records. |
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p1629732110412"><a name="p1629732110412"></a><a name="p1629732110412"></a>beginWrap(): RdbPredicates</p> | RdbPredicates | offsetAs(rowOffset:&nbsp;number):&nbsp;RdbPredicates | Sets the **RdbPredicates** to specify the start position of the returned result.<br>-&nbsp;**rowOffset**: start position of the returned result. The value is a positive integer.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that specifies the start position of the returned result. |
</td> | RdbPredicates | groupBy(fields:&nbsp;Array&lt;string&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to group rows that have the same value into summary rows.<br>-&nbsp;**fields**: names of the columns grouped for querying data.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that groups rows with the same value. |
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1334652112353"><a name="p1334652112353"></a><a name="p1334652112353"></a>Adds a left parenthesis to the <strong id="b183257951112554"><a name="b183257951112554"></a><a name="b183257951112554"></a>RdbPredicates</strong>.</p> | RdbPredicates | indexedBy(indexName:&nbsp;string):&nbsp;RdbPredicates | Sets the **RdbPredicates** to specify the index column.<br>-&nbsp;**indexName**: name of the index column.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that specifies the index column. |
<a name="ul3808195613915"></a><a name="ul3808195613915"></a><ul id="ul3808195613915"><li><strong id="b1146415308136"><a name="b1146415308136"></a><a name="b1146415308136"></a>RdbPredicates</strong>: <strong id="b145191852171313"><a name="b145191852171313"></a><a name="b145191852171313"></a>RdbPredicates</strong> with a left parenthesis.</li></ul> | RdbPredicates | in(field:&nbsp;string,&nbsp;value:&nbsp;Array&lt;ValueType&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value within the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: array of **ValueType** to match.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</td> | RdbPredicates | notIn(field:&nbsp;string,&nbsp;value:&nbsp;Array&lt;ValueType&gt;):&nbsp;RdbPredicates | Sets the **RdbPredicates** to match the field with data type **Array&#60;ValueType&#62;** and value out of the specified range.<br>-&nbsp;**field**: column name in the database table.<br>-&nbsp;**value**: array of **ValueType** to match.<br>-&nbsp;**RdbPredicates**: returns a **RdbPredicates** object that matches the specified field. |
</tr>
<tr id="row1034662163515"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1223456145516"><a name="p1223456145516"></a><a name="p1223456145516"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p4253185154216"><a name="p4253185154216"></a><a name="p4253185154216"></a>endWrap(): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1634620216353"><a name="p1634620216353"></a><a name="p1634620216353"></a>Adds a right parenthesis to the <strong id="b717084362112554"><a name="b717084362112554"></a><a name="b717084362112554"></a>RdbPredicates</strong>.</p>
<a name="ul952384823816"></a><a name="ul952384823816"></a><ul id="ul952384823816"><li><strong id="b622114010147"><a name="b622114010147"></a><a name="b622114010147"></a>RdbPredicates</strong>: <strong id="b92234051419"><a name="b92234051419"></a><a name="b92234051419"></a>RdbPredicates</strong> with a right parenthesis.</li></ul>
</td>
</tr>
<tr id="row193467215353"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1223856175513"><a name="p1223856175513"></a><a name="p1223856175513"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p782515201423"><a name="p782515201423"></a><a name="p782515201423"></a>or(): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p934672153514"><a name="p934672153514"></a><a name="p934672153514"></a>Adds the OR condition to the <strong id="b1180485437112554"><a name="b1180485437112554"></a><a name="b1180485437112554"></a>RdbPredicates</strong>.</p>
<a name="ul1431681603915"></a><a name="ul1431681603915"></a><ul id="ul1431681603915"><li><strong id="b439496101515"><a name="b439496101515"></a><a name="b439496101515"></a>RdbPredicates</strong>: <strong id="b1839456191515"><a name="b1839456191515"></a><a name="b1839456191515"></a>RdbPredicates</strong> with the OR condition.</li></ul>
</td>
</tr>
<tr id="row158263516300"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1282615143010"><a name="p1282615143010"></a><a name="p1282615143010"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p9222442144210"><a name="p9222442144210"></a><a name="p9222442144210"></a>and(): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1388710815510"><a name="p1388710815510"></a><a name="p1388710815510"></a>Adds the AND condition to the <strong id="b257471589112554"><a name="b257471589112554"></a><a name="b257471589112554"></a>RdbPredicates</strong>.</p>
<a name="ul1727699185710"></a><a name="ul1727699185710"></a><ul id="ul1727699185710"><li><strong id="b18566227141510"><a name="b18566227141510"></a><a name="b18566227141510"></a>RdbPredicates</strong>: <strong id="b185661227171511"><a name="b185661227171511"></a><a name="b185661227171511"></a>RdbPredicates</strong> with the AND condition.</li></ul>
</td>
</tr>
<tr id="row243103215346"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p114393263410"><a name="p114393263410"></a><a name="p114393263410"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p691261154313"><a name="p691261154313"></a><a name="p691261154313"></a>contains(field: string, value: string): RdbPredicats</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p138987821811"><a name="p138987821811"></a><a name="p138987821811"></a>Sets the <strong id="b1636898418112554"><a name="b1636898418112554"></a><a name="b1636898418112554"></a>RdbPredicates</strong> to match a string containing the specified value.</p>
<a name="ul187302357573"></a><a name="ul187302357573"></a><ul id="ul187302357573"><li><strong id="b0662138791"><a name="b0662138791"></a><a name="b0662138791"></a>field</strong>: column name in the database table.</li><li><strong id="b7114767121"><a name="b7114767121"></a><a name="b7114767121"></a>value</strong>: value to match the <strong id="b611466151215"><a name="b611466151215"></a><a name="b611466151215"></a>RdbPredicates</strong>.</li><li>RdbPredicates: <strong id="b14967161332010"><a name="b14967161332010"></a><a name="b14967161332010"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row1823275015527"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p172327507529"><a name="p172327507529"></a><a name="p172327507529"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p111451435154314"><a name="p111451435154314"></a><a name="p111451435154314"></a>beginsWith(field: string, value: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p102321950135210"><a name="p102321950135210"></a><a name="p102321950135210"></a>Sets the <strong id="b895587112554"><a name="b895587112554"></a><a name="b895587112554"></a>RdbPredicates</strong> to match a string that starts with the specified value.</p>
<a name="ul3643102216597"></a><a name="ul3643102216597"></a><ul id="ul3643102216597"><li><strong id="b176634812918"><a name="b176634812918"></a><a name="b176634812918"></a>field</strong>: column name in the database table.</li><li><strong id="b91196671210"><a name="b91196671210"></a><a name="b91196671210"></a>value</strong>: value to match the <strong id="b12119865128"><a name="b12119865128"></a><a name="b12119865128"></a>RdbPredicates</strong>.</li><li><strong id="b163192043181211"><a name="b163192043181211"></a><a name="b163192043181211"></a>RdbPredicates</strong>: <strong id="b13191043101217"><a name="b13191043101217"></a><a name="b13191043101217"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row86756195213"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p566562527"><a name="p566562527"></a><a name="p566562527"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p46356185216"><a name="p46356185216"></a><a name="p46356185216"></a>endsWith(field: string, value: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1063562529"><a name="p1063562529"></a><a name="p1063562529"></a>Sets the <strong id="b1056875172112554"><a name="b1056875172112554"></a><a name="b1056875172112554"></a>RdbPredicates</strong> to match a string that ends with the specified value.</p>
<a name="ul6905132213012"></a><a name="ul6905132213012"></a><ul id="ul6905132213012"><li><strong id="b46643820919"><a name="b46643820919"></a><a name="b46643820919"></a>field</strong>: column name in the database table.</li><li><strong id="b121239671216"><a name="b121239671216"></a><a name="b121239671216"></a>value</strong>: value to match the <strong id="b912317619121"><a name="b912317619121"></a><a name="b912317619121"></a>RdbPredicates</strong>.</li><li><strong id="b103211043131213"><a name="b103211043131213"></a><a name="b103211043131213"></a>RdbPredicates</strong>: <strong id="b20321104319124"><a name="b20321104319124"></a><a name="b20321104319124"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row58214297537"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p3822152917531"><a name="p3822152917531"></a><a name="p3822152917531"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p696112904411"><a name="p696112904411"></a><a name="p696112904411"></a>isNull(field: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p2822172913538"><a name="p2822172913538"></a><a name="p2822172913538"></a>Sets the <strong id="b1194045299112554"><a name="b1194045299112554"></a><a name="b1194045299112554"></a>RdbPredicates</strong> to match the field whose value is <strong id="b1890023078112554"><a name="b1890023078112554"></a><a name="b1890023078112554"></a>null</strong>.</p>
<a name="ul152823233592"></a><a name="ul152823233592"></a><ul id="ul152823233592"><li><strong id="b206641881994"><a name="b206641881994"></a><a name="b206641881994"></a>field</strong>: column name in the database table.</li><li><strong id="b1774115571093"><a name="b1774115571093"></a><a name="b1774115571093"></a>RdbPredicates</strong>: <strong id="b18741165710911"><a name="b18741165710911"></a><a name="b18741165710911"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row9134111680"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1513421388"><a name="p1513421388"></a><a name="p1513421388"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p08046261449"><a name="p08046261449"></a><a name="p08046261449"></a>isNotNull(field: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p7520112182316"><a name="p7520112182316"></a><a name="p7520112182316"></a>Sets the <strong id="b1059930094112554"><a name="b1059930094112554"></a><a name="b1059930094112554"></a>RdbPredicates</strong> to match the field whose value is not <strong id="b172403177112554"><a name="b172403177112554"></a><a name="b172403177112554"></a>null</strong>.</p>
<a name="ul5646142816017"></a><a name="ul5646142816017"></a><ul id="ul5646142816017"><li><strong id="b1366598494"><a name="b1366598494"></a><a name="b1366598494"></a>field</strong>: column name in the database table.</li><li><strong id="b355418851019"><a name="b355418851019"></a><a name="b355418851019"></a>RdbPredicates</strong>: <strong id="b15541983103"><a name="b15541983103"></a><a name="b15541983103"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row1543514416811"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p643516419810"><a name="p643516419810"></a><a name="p643516419810"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p15758134720442"><a name="p15758134720442"></a><a name="p15758134720442"></a>like(field: string, value: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p753485217231"><a name="p753485217231"></a><a name="p753485217231"></a>Sets the <strong id="b964300928112554"><a name="b964300928112554"></a><a name="b964300928112554"></a>RdbPredicates</strong> to match a string that is similar to the specified value.</p>
<a name="ul15439141112"></a><a name="ul15439141112"></a><ul id="ul15439141112"><li><strong id="b1366618991"><a name="b1366618991"></a><a name="b1366618991"></a>field</strong>: column name in the database table.</li><li><strong id="b11277641210"><a name="b11277641210"></a><a name="b11277641210"></a>value</strong>: value to match the <strong id="b121272065124"><a name="b121272065124"></a><a name="b121272065124"></a>RdbPredicates</strong>.</li><li><strong id="b19556158101012"><a name="b19556158101012"></a><a name="b19556158101012"></a>RdbPredicates</strong>: <strong id="b1556484106"><a name="b1556484106"></a><a name="b1556484106"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row1596914712820"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p169691871785"><a name="p169691871785"></a><a name="p169691871785"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p372713974512"><a name="p372713974512"></a><a name="p372713974512"></a>glob(field: string, value: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p14252854172320"><a name="p14252854172320"></a><a name="p14252854172320"></a>Sets the <strong id="b644369182112554"><a name="b644369182112554"></a><a name="b644369182112554"></a>RdbPredicates</strong> to match the specified string.</p>
<a name="ul18503142413115"></a><a name="ul18503142413115"></a><ul id="ul18503142413115"><li><strong id="b5667581899"><a name="b5667581899"></a><a name="b5667581899"></a>field</strong>: column name in the database table.</li><li><strong id="b10131460122"><a name="b10131460122"></a><a name="b10131460122"></a>value</strong>: value to match the <strong id="b1313176191214"><a name="b1313176191214"></a><a name="b1313176191214"></a>RdbPredicates</strong>.</li><li><strong id="b125581984106"><a name="b125581984106"></a><a name="b125581984106"></a>RdbPredicates</strong>: <strong id="b955819810103"><a name="b955819810103"></a><a name="b955819810103"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row142751730101"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p192751938103"><a name="p192751938103"></a><a name="p192751938103"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p36191533114513"><a name="p36191533114513"></a><a name="p36191533114513"></a>between(field: string, low: ValueType, high: ValueType): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1827513201020"><a name="p1827513201020"></a><a name="p1827513201020"></a>Sets the <strong id="b625856712112554"><a name="b625856712112554"></a><a name="b625856712112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b489101076112554"><a name="b489101076112554"></a><a name="b489101076112554"></a>ValueType</strong> and value within the specified range.</p>
<a name="ul3448133612117"></a><a name="ul3448133612117"></a><ul id="ul3448133612117"><li><strong id="b46682814917"><a name="b46682814917"></a><a name="b46682814917"></a>field</strong>: column name in the database table.</li><li><strong id="b062216817256"><a name="b062216817256"></a><a name="b062216817256"></a>low</strong>: minimum value that matches the <strong id="b4408649182510"><a name="b4408649182510"></a><a name="b4408649182510"></a>RdbPredicates</strong>.</li><li><strong id="b1336881318253"><a name="b1336881318253"></a><a name="b1336881318253"></a>high</strong>: maximum value that matches the <strong id="b05634512611"><a name="b05634512611"></a><a name="b05634512611"></a>RdbPredicates</strong>.</li><li><strong id="b135596841010"><a name="b135596841010"></a><a name="b135596841010"></a>RdbPredicates</strong>: <strong id="b1555913891013"><a name="b1555913891013"></a><a name="b1555913891013"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row18738551100"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p57388541019"><a name="p57388541019"></a><a name="p57388541019"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p102541595465"><a name="p102541595465"></a><a name="p102541595465"></a>notBetween(field: string, low: ValueType, high: ValueType): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1073914511013"><a name="p1073914511013"></a><a name="p1073914511013"></a>Sets the <strong id="b480030174112554"><a name="b480030174112554"></a><a name="b480030174112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b591370903112554"><a name="b591370903112554"></a><a name="b591370903112554"></a>ValueType</strong> and value out of the specified range.</p>
<a name="ul697416399210"></a><a name="ul697416399210"></a><ul id="ul697416399210"><li><strong id="b136681086914"><a name="b136681086914"></a><a name="b136681086914"></a>field</strong>: column name in the database table.</li><li><strong id="b4395132016267"><a name="b4395132016267"></a><a name="b4395132016267"></a>low</strong>: minimum value that matches the <strong id="b0396182092615"><a name="b0396182092615"></a><a name="b0396182092615"></a>RdbPredicates</strong>.</li><li><strong id="b16568182820262"><a name="b16568182820262"></a><a name="b16568182820262"></a>high</strong>: maximum value that matches the <strong id="b12568128132611"><a name="b12568128132611"></a><a name="b12568128132611"></a>RdbPredicates</strong>.</li><li><strong id="b25607881011"><a name="b25607881011"></a><a name="b25607881011"></a>RdbPredicates</strong>: <strong id="b256013819104"><a name="b256013819104"></a><a name="b256013819104"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row2946551141115"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p17946195191118"><a name="p17946195191118"></a><a name="p17946195191118"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p86191537184610"><a name="p86191537184610"></a><a name="p86191537184610"></a>greaterThan(field: string, value: ValueType): RdbPredicatesgr</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p129461514117"><a name="p129461514117"></a><a name="p129461514117"></a>Sets the <strong id="b299934469112554"><a name="b299934469112554"></a><a name="b299934469112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b297820682112554"><a name="b297820682112554"></a><a name="b297820682112554"></a>ValueType</strong> and value greater than the specified value.</p>
<a name="ul11811341539"></a><a name="ul11811341539"></a><ul id="ul11811341539"><li><strong id="b116691285910"><a name="b116691285910"></a><a name="b116691285910"></a>field</strong>: column name in the database table.</li><li><strong id="b7135166141214"><a name="b7135166141214"></a><a name="b7135166141214"></a>value</strong>: value to match the <strong id="b71351460123"><a name="b71351460123"></a><a name="b71351460123"></a>RdbPredicates</strong>.</li><li><strong id="b9561138131015"><a name="b9561138131015"></a><a name="b9561138131015"></a>RdbPredicates</strong>: <strong id="b1561584103"><a name="b1561584103"></a><a name="b1561584103"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row4947195461118"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p149481654191110"><a name="p149481654191110"></a><a name="p149481654191110"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p3948205414117"><a name="p3948205414117"></a><a name="p3948205414117"></a>lessThan(field: string, value: ValueType): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1150510191493"><a name="p1150510191493"></a><a name="p1150510191493"></a>Sets the <strong id="b998950278112554"><a name="b998950278112554"></a><a name="b998950278112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b1745313530112554"><a name="b1745313530112554"></a><a name="b1745313530112554"></a>ValueType</strong> and value less than the specified value.</p>
<a name="ul1641512392313"></a><a name="ul1641512392313"></a><ul id="ul1641512392313"><li><strong id="b367014815919"><a name="b367014815919"></a><a name="b367014815919"></a>field</strong>: column name in the database table.</li><li><strong id="b213966181219"><a name="b213966181219"></a><a name="b213966181219"></a>value</strong>: value to match the <strong id="b161391269123"><a name="b161391269123"></a><a name="b161391269123"></a>RdbPredicates</strong>.</li><li><strong id="b17562183104"><a name="b17562183104"></a><a name="b17562183104"></a>RdbPredicates</strong>: <strong id="b156228141013"><a name="b156228141013"></a><a name="b156228141013"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row10618151417129"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p26189149128"><a name="p26189149128"></a><a name="p26189149128"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p16430131913473"><a name="p16430131913473"></a><a name="p16430131913473"></a>greaterThanOrEqualTo(field: string, value: ValueType): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p1496111155113"><a name="p1496111155113"></a><a name="p1496111155113"></a>Sets the <strong id="b349869843112554"><a name="b349869843112554"></a><a name="b349869843112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b634300709112554"><a name="b634300709112554"></a><a name="b634300709112554"></a>ValueType</strong> and value greater than or equal to the specified value.</p>
<a name="ul1169911541738"></a><a name="ul1169911541738"></a><ul id="ul1169911541738"><li><strong id="b86711689917"><a name="b86711689917"></a><a name="b86711689917"></a>field</strong>: column name in the database table.</li><li><strong id="b71443641215"><a name="b71443641215"></a><a name="b71443641215"></a>value</strong>: value to match the <strong id="b414420621215"><a name="b414420621215"></a><a name="b414420621215"></a>RdbPredicates</strong>.</li><li><strong id="b3563189109"><a name="b3563189109"></a><a name="b3563189109"></a>RdbPredicates</strong>: <strong id="b6563168171010"><a name="b6563168171010"></a><a name="b6563168171010"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row7691627151211"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p1969427131213"><a name="p1969427131213"></a><a name="p1969427131213"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p34348284483"><a name="p34348284483"></a><a name="p34348284483"></a>lessThanOrEqualTo(field: string, value: ValueType): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p12181611535"><a name="p12181611535"></a><a name="p12181611535"></a>Sets the <strong id="b312137118112554"><a name="b312137118112554"></a><a name="b312137118112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b304585139112554"><a name="b304585139112554"></a><a name="b304585139112554"></a>ValueType</strong> and value less than or equal to the specified value.</p>
<a name="ul954651146"></a><a name="ul954651146"></a><ul id="ul954651146"><li><strong id="b3672785911"><a name="b3672785911"></a><a name="b3672785911"></a>field</strong>: column name in the database table.</li><li><strong id="b14148146141213"><a name="b14148146141213"></a><a name="b14148146141213"></a>value</strong>: value to match the <strong id="b21481362121"><a name="b21481362121"></a><a name="b21481362121"></a>RdbPredicates</strong>.</li><li><strong id="b1056414811010"><a name="b1056414811010"></a><a name="b1056414811010"></a>RdbPredicates</strong>: <strong id="b20564128141016"><a name="b20564128141016"></a><a name="b20564128141016"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row131173871211"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p15110384126"><a name="p15110384126"></a><a name="p15110384126"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p12573121712492"><a name="p12573121712492"></a><a name="p12573121712492"></a>orderByAsc(field: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p31119384125"><a name="p31119384125"></a><a name="p31119384125"></a>Sets the <strong id="b688515142112554"><a name="b688515142112554"></a><a name="b688515142112554"></a>RdbPredicates</strong> to match the column with values sorted in ascending order.</p>
<a name="ul12611201211416"></a><a name="ul12611201211416"></a><ul id="ul12611201211416"><li><strong id="b20672881395"><a name="b20672881395"></a><a name="b20672881395"></a>field</strong>: column name in the database table.</li><li><strong id="b4565481101"><a name="b4565481101"></a><a name="b4565481101"></a>RdbPredicates</strong>: <strong id="b1956515816107"><a name="b1956515816107"></a><a name="b1956515816107"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row112261741171218"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p422611417127"><a name="p422611417127"></a><a name="p422611417127"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p622664161218"><a name="p622664161218"></a><a name="p622664161218"></a>orderByDesc(field: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p152261741201214"><a name="p152261741201214"></a><a name="p152261741201214"></a>Sets the <strong id="b1784358755112554"><a name="b1784358755112554"></a><a name="b1784358755112554"></a>RdbPredicates</strong> to match the column with values sorted in descending order.</p>
<a name="ul17931024747"></a><a name="ul17931024747"></a><ul id="ul17931024747"><li><strong id="b106731081197"><a name="b106731081197"></a><a name="b106731081197"></a>field</strong>: column name in the database table.</li><li><strong id="b15661871013"><a name="b15661871013"></a><a name="b15661871013"></a>RdbPredicates</strong>: <strong id="b55664821014"><a name="b55664821014"></a><a name="b55664821014"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row9961113773315"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p29616370334"><a name="p29616370334"></a><a name="p29616370334"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p9260141911516"><a name="p9260141911516"></a><a name="p9260141911516"></a>distinct(): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p79613373335"><a name="p79613373335"></a><a name="p79613373335"></a>Sets the <strong id="b1849038781112554"><a name="b1849038781112554"></a><a name="b1849038781112554"></a>RdbPredicates</strong> to filter out duplicate records.</p>
<a name="ul9247643548"></a><a name="ul9247643548"></a><ul id="ul9247643548"><li><strong id="b8216555102712"><a name="b8216555102712"></a><a name="b8216555102712"></a>RdbPredicates</strong>: <strong id="b154056214288"><a name="b154056214288"></a><a name="b154056214288"></a>RdbPredicates</strong> that can filter out duplicate records.</li></ul>
</td>
</tr>
<tr id="row117447163520"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p167444123514"><a name="p167444123514"></a><a name="p167444123514"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p1744191163517"><a name="p1744191163517"></a><a name="p1744191163517"></a>limitAs(value: number): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p167441813355"><a name="p167441813355"></a><a name="p167441813355"></a>Sets the <strong id="b1852235509112554"><a name="b1852235509112554"></a><a name="b1852235509112554"></a>RdbPredicates</strong> to specify the maximum number of records to match in a column.</p>
<a name="ul99331016519"></a><a name="ul99331016519"></a><ul id="ul99331016519"><li><strong id="b1066132843113"><a name="b1066132843113"></a><a name="b1066132843113"></a>value</strong>: maximum number of records in a column.</li><li><strong id="b2596134933112"><a name="b2596134933112"></a><a name="b2596134933112"></a>RdbPredicates</strong>: <strong id="b17201911321"><a name="b17201911321"></a><a name="b17201911321"></a>RdbPredicates</strong> that can be used to set the maximum number of records to match in a column.</li></ul>
</td>
</tr>
<tr id="row13215105816343"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p192151858183419"><a name="p192151858183419"></a><a name="p192151858183419"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p9259827135217"><a name="p9259827135217"></a><a name="p9259827135217"></a>offsetAs(rowOffset: number): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p621595810347"><a name="p621595810347"></a><a name="p621595810347"></a>Sets the <strong id="b330697748112554"><a name="b330697748112554"></a><a name="b330697748112554"></a>RdbPredicates</strong> to specify the start position of the returned result.</p>
<a name="ul16890144017919"></a><a name="ul16890144017919"></a><ul id="ul16890144017919"><li><strong id="b4801398332"><a name="b4801398332"></a><a name="b4801398332"></a>rowOffset</strong>: start position of the returned result. The value is a positive integer.</li><li><strong id="b15974182419334"><a name="b15974182419334"></a><a name="b15974182419334"></a>RdbPredicates</strong>: <strong id="b117772378336"><a name="b117772378336"></a><a name="b117772378336"></a>RdbPredicates</strong> object that specifies the start position of the returned result.</li></ul>
</td>
</tr>
<tr id="row149737835713"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p119730835711"><a name="p119730835711"></a><a name="p119730835711"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p1132724295212"><a name="p1132724295212"></a><a name="p1132724295212"></a>groupBy(fields: Array&lt;string&gt;): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p315610216119"><a name="p315610216119"></a><a name="p315610216119"></a>Sets the <strong id="b922906078112554"><a name="b922906078112554"></a><a name="b922906078112554"></a>RdbPredicates</strong> to group rows that have the same value into summary rows.</p>
<a name="ul048292611102"></a><a name="ul048292611102"></a><ul id="ul048292611102"><li><strong id="b12152152614219"><a name="b12152152614219"></a><a name="b12152152614219"></a>fields</strong>: names of the columns grouped for querying data.</li><li><strong id="b107111444315"><a name="b107111444315"></a><a name="b107111444315"></a>RdbPredicates</strong>: <strong id="b1693008184315"><a name="b1693008184315"></a><a name="b1693008184315"></a>RdbPredicates</strong> that groups rows that have the same value.</li></ul>
</td>
</tr>
<tr id="row1938314155717"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p23836465712"><a name="p23836465712"></a><a name="p23836465712"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p14827457175217"><a name="p14827457175217"></a><a name="p14827457175217"></a>indexedBy(indexName: string): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p784844513588"><a name="p784844513588"></a><a name="p784844513588"></a>Sets the <strong id="b1547335609112554"><a name="b1547335609112554"></a><a name="b1547335609112554"></a>RdbPredicates</strong> object to specify the index column.</p>
<a name="ul14142173351011"></a><a name="ul14142173351011"></a><ul id="ul14142173351011"><li><strong id="b74784474315"><a name="b74784474315"></a><a name="b74784474315"></a>indexName</strong>: name of the index column.</li><li><strong id="b8808413154415"><a name="b8808413154415"></a><a name="b8808413154415"></a>RdbPredicates</strong>: <strong id="b3808141812449"><a name="b3808141812449"></a><a name="b3808141812449"></a>RdbPredicates</strong> object that specifies the index column.</li></ul>
</td>
</tr>
<tr id="row147916365529"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p157922036145218"><a name="p157922036145218"></a><a name="p157922036145218"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p17428713185312"><a name="p17428713185312"></a><a name="p17428713185312"></a>in(field: string, value: Array&lt;ValueType&gt;): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p12468144012181"><a name="p12468144012181"></a><a name="p12468144012181"></a>Sets the <strong id="b1089824940112554"><a name="b1089824940112554"></a><a name="b1089824940112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b1982339248112554"><a name="b1982339248112554"></a><a name="b1982339248112554"></a>Array&lt;ValueType&gt;</strong> and value within the specified range.</p>
<a name="ul1261343010160"></a><a name="ul1261343010160"></a><ul id="ul1261343010160"><li><strong id="b2674281693"><a name="b2674281693"></a><a name="b2674281693"></a>field</strong>: column name in the database table.</li></ul>
<a name="ul12498383105"></a><a name="ul12498383105"></a><ul id="ul12498383105"><li><strong id="b495499154512"><a name="b495499154512"></a><a name="b495499154512"></a>value</strong>: array of <strong id="b161531382454"><a name="b161531382454"></a><a name="b161531382454"></a>ValueType</strong> to match.</li><li><strong id="b145677817100"><a name="b145677817100"></a><a name="b145677817100"></a>RdbPredicates</strong>: <strong id="b8567178151019"><a name="b8567178151019"></a><a name="b8567178151019"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
<tr id="row16668112817533"><td class="cellrowborder" valign="top" width="13.850000000000001%" headers="mcps1.2.4.1.1 "><p id="p146689283532"><a name="p146689283532"></a><a name="p146689283532"></a>RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="39.910000000000004%" headers="mcps1.2.4.1.2 "><p id="p74983294532"><a name="p74983294532"></a><a name="p74983294532"></a>notIn(field: string, value: Array&lt;ValueType&gt;): RdbPredicates</p>
</td>
<td class="cellrowborder" valign="top" width="46.239999999999995%" headers="mcps1.2.4.1.3 "><p id="p2066842875317"><a name="p2066842875317"></a><a name="p2066842875317"></a>Sets the <strong id="b2092907677112554"><a name="b2092907677112554"></a><a name="b2092907677112554"></a>RdbPredicates</strong> to match the field with data type <strong id="b30969258112554"><a name="b30969258112554"></a><a name="b30969258112554"></a>Array&lt;ValueType&gt;</strong> and value out of the specified range.</p>
<a name="ul2699143755811"></a><a name="ul2699143755811"></a><ul id="ul2699143755811"><li><strong id="b56756812910"><a name="b56756812910"></a><a name="b56756812910"></a>field</strong>: column name in the database table.</li></ul>
<a name="ul93771585122"></a><a name="ul93771585122"></a><ul id="ul93771585122"><li><strong id="b447917884619"><a name="b447917884619"></a><a name="b447917884619"></a>value</strong>: array of <strong id="b144791884611"><a name="b144791884611"></a><a name="b144791884611"></a>ValueType</strong> to match.</li><li><strong id="b155684813104"><a name="b155684813104"></a><a name="b155684813104"></a>RdbPredicates</strong>: <strong id="b115680813101"><a name="b115680813101"></a><a name="b115680813101"></a>RdbPredicates</strong> object that matches the specified field.</li></ul>
</td>
</tr>
</tbody>
</table>
**Using the Result Set** **Using the Result Set**
A result set can be regarded as rows of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. A result set can be regarded as a row of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**.
>![](public_sys-resources/icon-notice.gif) **NOTICE:** > ![icon-notice.gif](public_sys-resources/icon-notice.gif) **NOTICE**
>After a result set is used, you must call the **close\(\)** method to close it explicitly. > After a result set is used, you must call the **close()** method to close it explicitly.
**Table 7** APIs for using the result set **Table 7** APIs for using the result set
<a name="table20837141217325"></a> | Class| API| Description|
<table><thead align="left"><tr id="row100121314329"><th class="cellrowborder" valign="top" width="10.24%" id="mcps1.2.4.1.1"><p id="p775412912565"><a name="p775412912565"></a><a name="p775412912565"></a>Class</p> | -------- | -------- | -------- |
</th> | ResultSet | goTo(offset:number):&nbsp;boolean | Moves the result set forwards or backwards by the specified offset relative to its current position.|
<th class="cellrowborder" valign="top" width="43.46%" id="mcps1.2.4.1.2"><p id="p191913173219"><a name="p191913173219"></a><a name="p191913173219"></a>API</p> | ResultSet | goToRow(position:&nbsp;number):&nbsp;boolean | Moves the result set to the specified row.|
</th> | ResultSet | goToNextRow():&nbsp;boolean | Moves the result set to the next row.|
<th class="cellrowborder" valign="top" width="46.300000000000004%" id="mcps1.2.4.1.3"><p id="p12171318326"><a name="p12171318326"></a><a name="p12171318326"></a>Description</p> | ResultSet | goToPreviousRow():&nbsp;boolean | Moves the result set to the previous row.|
</th> | ResultSet | getColumnIndex(columnName:&nbsp;string):&nbsp;number | Obtains the column index based on the specified column name.|
</tr> | ResultSet | getColumnName(columnIndex:&nbsp;number):&nbsp;string | Obtains the column name based on the specified column index.|
</thead> | ResultSet | goToFirstRow():&nbsp;boolean | Checks whether the result set is located in the first row.|
<tbody><tr id="row520911313181"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p75383261001"><a name="p75383261001"></a><a name="p75383261001"></a>ResultSet</p> | ResultSet | goToLastRow():&nbsp;boolean | Checks whether the result set is located in the last row.|
</td> | ResultSet | getString(columnIndex:&nbsp;number):&nbsp;string | Obtains the value in the specified column of the current row, in a string.|
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p19210173118180"><a name="p19210173118180"></a><a name="p19210173118180"></a>goTo(offset:number): boolean</p> | ResultSet | getBlob(columnIndex:&nbsp;number):&nbsp;Uint8Array | Obtains the values in the specified column of the current row, in a byte array.|
</td> | ResultSet | getDouble(columnIndex:&nbsp;number):&nbsp;number | Obtains the values in the specified column of the current row, in double.|
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p9210183113187"><a name="p9210183113187"></a><a name="p9210183113187"></a>Moves the result set forwards or backwards by an offset relative to its current position.</p> | ResultSet | isColumnNull(columnIndex:&nbsp;number):&nbsp;boolean | Checks whether the value in the specified column of the current row is null.|
</td> | ResultSet | close():&nbsp;void | Closes the result set.|
</tr>
<tr id="row71141310323"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p175442935616"><a name="p175442935616"></a><a name="p175442935616"></a>ResultSet</p> **Changing the Encryption Key for an RDB Store**
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p1233611818317"><a name="p1233611818317"></a><a name="p1233611818317"></a>goToRow(position: number): boolean</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p141113153210"><a name="p141113153210"></a><a name="p141113153210"></a>Moves the result set to a specified row.</p>
</td>
</tr>
<tr id="row1923137323"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p1875442945615"><a name="p1875442945615"></a><a name="p1875442945615"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p19769183218312"><a name="p19769183218312"></a><a name="p19769183218312"></a>goToNextRow(): boolean</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p627132327"><a name="p627132327"></a><a name="p627132327"></a>Moves the result set to the next row.</p>
</td>
</tr>
<tr id="row1281316329"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p275462918568"><a name="p275462918568"></a><a name="p275462918568"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p142131311326"><a name="p142131311326"></a><a name="p142131311326"></a>goToPreviousRow(): boolean</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p1321813143210"><a name="p1321813143210"></a><a name="p1321813143210"></a>Moves the result set to the previous row.</p>
</td>
</tr>
<tr id="row1527137326"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p137542291560"><a name="p137542291560"></a><a name="p137542291560"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p191361958746"><a name="p191361958746"></a><a name="p191361958746"></a>getColumnIndex(columnName: string): number</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p0315135329"><a name="p0315135329"></a><a name="p0315135329"></a>Obtains the column index based on the specified column name.</p>
</td>
</tr>
<tr id="row53181383215"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p3754329125618"><a name="p3754329125618"></a><a name="p3754329125618"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p119675317520"><a name="p119675317520"></a><a name="p119675317520"></a>getColumnName(columnIndex: number): string</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p4341363212"><a name="p4341363212"></a><a name="p4341363212"></a>Obtains the column name based on the specified column index.</p>
</td>
</tr>
<tr id="row153013153216"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p19754172985613"><a name="p19754172985613"></a><a name="p19754172985613"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p14878197175"><a name="p14878197175"></a><a name="p14878197175"></a>goToFirstRow(): boolean</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p153513123219"><a name="p153513123219"></a><a name="p153513123219"></a>Checks whether the result set is located in the first row.</p>
</td>
</tr>
<tr id="row153413123212"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p137544291567"><a name="p137544291567"></a><a name="p137544291567"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p73121318325"><a name="p73121318325"></a><a name="p73121318325"></a>goToLastRow(): boolean</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p13381311321"><a name="p13381311321"></a><a name="p13381311321"></a>Checks whether the result set is located in the last row.</p>
</td>
</tr>
<tr id="row64313153214"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p14755629205616"><a name="p14755629205616"></a><a name="p14755629205616"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p6428451185"><a name="p6428451185"></a><a name="p6428451185"></a>getString(columnIndex: number): string</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p1651713173216"><a name="p1651713173216"></a><a name="p1651713173216"></a>Obtains the values in the specified column of the current row, in strings.</p>
</td>
</tr>
<tr id="row1052133323"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p77551529175612"><a name="p77551529175612"></a><a name="p77551529175612"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p95561131987"><a name="p95561131987"></a><a name="p95561131987"></a>getBlob(columnIndex: number): Uint8Array</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p1553134322"><a name="p1553134322"></a><a name="p1553134322"></a>Obtains the values in the specified column of the current row, in a byte array.</p>
</td>
</tr>
<tr id="row95113123215"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p5755112965619"><a name="p5755112965619"></a><a name="p5755112965619"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p1426859998"><a name="p1426859998"></a><a name="p1426859998"></a>getDouble(columnIndex: number): number</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p1854135329"><a name="p1854135329"></a><a name="p1854135329"></a>Obtains the values in the specified column of the current row, in double.</p>
</td>
</tr>
<tr id="row0297182413110"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p029811248111"><a name="p029811248111"></a><a name="p029811248111"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p529822420110"><a name="p529822420110"></a><a name="p529822420110"></a>isColumnNull(columnIndex: number): boolean</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p929814244115"><a name="p929814244115"></a><a name="p929814244115"></a>Checks whether the values in the specified column of the current row are <strong id="b1342751713112554"><a name="b1342751713112554"></a><a name="b1342751713112554"></a>null</strong>.</p>
</td>
</tr>
<tr id="row142400459115"><td class="cellrowborder" valign="top" width="10.24%" headers="mcps1.2.4.1.1 "><p id="p12401445191113"><a name="p12401445191113"></a><a name="p12401445191113"></a>ResultSet</p>
</td>
<td class="cellrowborder" valign="top" width="43.46%" headers="mcps1.2.4.1.2 "><p id="p132401145151118"><a name="p132401145151118"></a><a name="p132401145151118"></a>close(): void</p>
</td>
<td class="cellrowborder" valign="top" width="46.300000000000004%" headers="mcps1.2.4.1.3 "><p id="p16240104519118"><a name="p16240104519118"></a><a name="p16240104519118"></a>Closes the result set.</p>
</td>
</tr>
</tbody>
</table>
**Encrypting an RDB Store**
You can encrypt an RDB store. You can encrypt an RDB store.
When creating an RDB store, you can add a key for security purposes. After that, the RDB store can be accessed only with the correct key. You can change the key but cannot delete it. When creating an RDB store, you can add a key for security purposes. After that, the RDB store can be accessed only with the correct key. You can change the key but cannot delete it.
Once an RDB store is created without a key, you cannot add a key any longer. Once an RDB store is created without a key, you can no longer add a key for it.
**Table 8** APIs for changing the key
<a name="table1162415825016"></a>
<table><thead align="left"><tr id="row1262417589509"><th class="cellrowborder" valign="top" width="12.11%" id="mcps1.2.4.1.1"><p id="p15624135816506"><a name="p15624135816506"></a><a name="p15624135816506"></a>Class</p>
</th>
<th class="cellrowborder" valign="top" width="44.34%" id="mcps1.2.4.1.2"><p id="p1662465812509"><a name="p1662465812509"></a><a name="p1662465812509"></a>API</p>
</th>
<th class="cellrowborder" valign="top" width="43.55%" id="mcps1.2.4.1.3"><p id="p136246584502"><a name="p136246584502"></a><a name="p136246584502"></a>Description</p>
</th>
</tr>
</thead>
<tbody><tr id="row96251058195012"><td class="cellrowborder" valign="top" width="12.11%" headers="mcps1.2.4.1.1 "><p id="p062515819502"><a name="p062515819502"></a><a name="p062515819502"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="44.34%" headers="mcps1.2.4.1.2 "><p id="p99182034195712"><a name="p99182034195712"></a><a name="p99182034195712"></a>changeEncryptKey(newEncryptKey:Uint8Array, callback: AsyncCallback&lt;number&gt;):void;</p>
</td>
<td class="cellrowborder" valign="top" width="43.55%" headers="mcps1.2.4.1.3 "><p id="p4625115845012"><a name="p4625115845012"></a><a name="p4625115845012"></a>Changes the encryption key for an RDB store. This method uses a callback to return the result. If the key is changed, <strong id="b17911183611517"><a name="b17911183611517"></a><a name="b17911183611517"></a>0</strong> is returned. Otherwise, a non-zero value is returned.</p>
</td>
</tr>
<tr id="row1662575805017"><td class="cellrowborder" valign="top" width="12.11%" headers="mcps1.2.4.1.1 "><p id="p76252058165015"><a name="p76252058165015"></a><a name="p76252058165015"></a>RdbStore</p>
</td>
<td class="cellrowborder" valign="top" width="44.34%" headers="mcps1.2.4.1.2 "><p id="p1025394519554"><a name="p1025394519554"></a><a name="p1025394519554"></a>changeEncryptKey(newEncryptKey:Uint8Array): Promise&lt;number&gt;;</p>
</td>
<td class="cellrowborder" valign="top" width="43.55%" headers="mcps1.2.4.1.3 "><p id="p186252058175012"><a name="p186252058175012"></a><a name="p186252058175012"></a>Changes the encryption key for an RDB store. This method uses a promise to return the result. If the key is changed, <strong id="b4886609720"><a name="b4886609720"></a><a name="b4886609720"></a>0</strong> is returned. Otherwise, a non-zero value is returned.</p>
</td>
</tr>
</tbody>
</table>
## How to Develop<a name="section116922712311"></a>
1. Create an RDB store.
1. Configure the RDB attributes, including the name and storage mode of the database and whether it is read-only.
2. Initialize the table structure and related data in the database.
3. Create an RDB store.
The sample code is as follows: **Table 8** APIs for changing the encryption key
``` | Class| API| Description|
import dataRdb from '@ohos.data.rdb'; | -------- | -------- | -------- |
| RdbStore | changeEncryptKey(newEncryptKey:Uint8Array,&nbsp;callback:&nbsp;AsyncCallback&lt;number&gt;):void; | Changes the encryption key for this RDB store. This method uses a callback to return the result. If the operation is successful, **0** will be returned. Otherwise, a non-zero value will be returned.|
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; | RdbStore | changeEncryptKey(newEncryptKey:Uint8Array):&nbsp;Promise&lt;number&gt;; | Changes the encryption key for this RDB store. This method uses a promise to return the result. If the operation is successful, **0** will be returned. Otherwise, a non-zero value will be returned.|
const STORE_CONFIG = {name: "rdbstore.db",}
**Setting Distributed Tables**
let rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST); You can set a list of distributed tables for data operations across devices.
```
**Table 9** APIs for setting distributed tables
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | setDistributedTables(tables: Array<string>, callback: AsyncCallback<void>): void;| Sets a list of distributed tables. This method uses a callback to return the result.<br>- &nbsp;**tables**: names of the distributed tables to set.<br>-&nbsp;**callback**: callback invoked to return the result.|
| RdbStore | setDistributedTables(tables: Array<string>): Promise<void>; | Sets a list of distributed tables. This method uses a promise to return the result.<br>- &nbsp;**tables**: names of the distributed tables to set.|
**Obtaining the Distributed Table Name for a Remote Device**
You can obtain the distributed table name for a remote device based on the local table name. The distributed table name can be used to query the RDB store of the remote device.
**Table 10** API for obtaining the distributed table name of a remote device
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | obtainDistributedTableName(device: string, table: string, callback: AsyncCallback<string>): void; | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This method uses a callback to return the result.<br>-&nbsp;**device**: remote device.<br>- &nbsp;**table**: local table name.<br>- &nbsp;**callback**: callback used to return the result. If the operation is successful, the distributed table name of the remote device will be returned. |
| RdbStore | obtainDistributedTableName(device: string, table: string): Promise<string>; | Obtains the distributed table name for a remote device based on the local table name. The distributed table name is used to query the RDB store of the remote device. This method uses a promise to return the result.<br>-&nbsp;**device**: remote device.<br>- &nbsp;**table**: local table name.|
**Synchronizing Data Between Devices**
**Table 11** APIs for synchronizing data between devices
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates, callback: AsyncCallback<Array<[string, number]>>): void;| Synchronizes data between devices. This method uses a callback to return the result.<br>-&nbsp;**mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device.<br>-&nbsp;**predicates**: data and devices to be synchronized.<br>-&nbsp;**callback**: callback invoked to return the result. In the result, **string** indicates the device ID, and **number** indicates the synchronization status of each device. The value **0** indicates a success, and other values indicate a failure.|
| RdbStore | sync(mode: SyncMode, predicates: RdbPredicates): Promise<Array<[string, number]>>;| Synchronizes data between devices. This method uses a promise to return the result.<br>-&nbsp;**mode**: data synchronization mode. **SYNC\_MODE\_PUSH** means to push data from the local device to a remote device. **SYNC\_MODE\_PULL** means to pull data from a remote device to the local device.<br>-&nbsp;**predicates**: data and devices to be synchronized. |
**Registering an RDB Store Observer**
2. Insert data. **Table 12** API for registering an observer
1. Create a **ValuesBucket** object to store the data you need to insert. | Class| API| Description|
2. Call the **insert\(\)** method to insert data into the RDB store. | -------- | -------- | -------- |
| RdbStore |on(event: 'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void;| Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes.<br>-&nbsp;**type**: subscription type. **SUBSCRIBE\_TYPE\_REMOTE** means to subscribe to remote data changes.<br>-&nbsp;**observer**: observer that listens for data changes in the RDB store.|
**Unregistering an RDB Store Observer**
**Table 13** API for unregistering an observer
| Class| API| Description|
| -------- | -------- | -------- |
| RdbStore |off(event:'dataChange', type: SubscribeType, observer: Callback<Array<string>>): void;| Unregisters the observer of the specified type for the RDB store. This method uses a callback to return the result.<br>- &nbsp;**type**: subscription type. **SUBSCRIBE\_TYPE\_REMOTE** means to subscribe to remote data changes.<br>- &nbsp;**observer**: observer to unregister.|
## How to Develop
1. Create an RDB store.
1. Configure the RDB store attributes, including the RDB store name, storage mode, and whether read-only mode is used.
2. Initialize the table structure and related data in the RDB store.
3. Create the RDB store.
The sample code is as follows:
```
import dataRdb from '@ohos.data.rdb';
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
const STORE_CONFIG = {name: "rdbstore.db",}
let rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST);
```
2. Insert data.
1. Create a **ValuesBucket** to store the data you need to insert.
2. Call the **insert()** method to insert data into the RDB store.
The sample code is as follows:
```
var u8 = new Uint8Array([1, 2, 3])
const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,}
let insertPromise = rdbStore.insert("test", valueBucket)
```
3. Query data.
1. Create an **RdbPredicates** object to specify query conditions.
2. Call the **query()** method to query data.
3. Call the **ResultSet()** method to obtain the query result.
The sample code is as follows:
```
let predicates = new dataRdb.RdbPredicates("test");
predicates.equalTo("name", "Tom")
let resultSet = await rdbStore.query(predicates)
resultSet.goToFirstRow()
const id = await resultSet.getLong(resultSet.getColumnIndex("id"))
const name = await resultSet.getString(resultSet.getColumnIndex("name"))
const age = await resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = await resultSet.getDouble(resultSet.getColumnIndex("salary"))
const blobType = await resultSet.getBlob(resultSet.getColumnIndex("blobType"))
resultSet.close()
```
4. Set the distributed tables to be synchronized.
1. Set the distributed tables.
2. Check whether the setting is successful.
The sample code is as follows:
```
let promise = rdbStore.setDistributedTables(["test"])
promise.then(() => {
console.info("setDistributedTables success.")
}).catch((err) => {
console.info("setDistributedTables failed."")
})
```
5. Synchronize data across devices.
1. Constructs an **RdbPredicates** object to specify remote devices within the network to be synchronized.
2. Call the **sync()** method to synchronize data.
3. Check whether the data synchronization is successful.
The sample code is as follows: The sample code is as follows:
``` ```
var u8 = new Uint8Array([1, 2, 3]) let predicate = new dataRdb.RdbPredicates('test')
const valueBucket = {"name": "Tom", "age": 18, "salary": 100.5, "blobType": u8,} predicate.inDevices(['12345678abcde'])
let insertPromise = rdbStore.insert("test", valueBucket) let promise = rdbStore.sync(rdb.SyncMode.SYNC_MODE_PUSH, predicate)
promise.then(result) {
console.log('sync done.')
for (let i = 0; i < result.length; i++) {
console.log('device=' + result[i][0] + ' status=' + result[i][1])
}
}).catch((err) => {
console.log('sync failed')
})
``` ```
3. Query data. 6. Subscribe to distributed data.
1. Register an observer to listen for distributed data changes.
1. Create an **RdbPredicates** object to specify query conditions. 2. When data in the RDB store changes, a callback will be invoked to return the data changes.
2. Call the **query \(\)** method to query data in the RDB store.
3. Call the **ResultSet\(\)** method to obtain the query result.
The sample code is as follows: The sample code is as follows:
``` ```
let predicates = new dataRdb.RdbPredicates("test"); function storeObserver(devices) {
predicates.equalTo("name", "Tom") for (let i = 0; i < devices.length; i++) {
let resultSet = await rdbStore.query(predicates) console.log('device=' + device[i] + ' data changed')
}
resultSet.goToFirstRow() }
const id = await resultSet.getLong(resultSet.getColumnIndex("id")) try {
const name = await resultSet.getString(resultSet.getColumnIndex("name")) rdbStore.on('dataChange', rdb.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver)
const age = await resultSet.getLong(resultSet.getColumnIndex("age")) } catch (err) {
const salary = await resultSet.getDouble(resultSet.getColumnIndex("salary")) console.log('register observer failed')
const blobType = await resultSet.getBlob(resultSet.getColumnIndex("blobType")) }
resultSet.close()
``` ```
7. Query data across devices.
1. Obtain the distributed table name for a remote device based on the local table name.
2. Call the **ResultSet()** method to obtain the query result.
The sample code is as follows:
```
let tableName = rdbStore.obtainDistributedTableName(deviceId, "test");
let resultSet = rdbStore.querySql("SELECT * FROM " + tableName)
```
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
- [App Storage Statistics](js-apis-storage-statistics.md) - [App Storage Statistics](js-apis-storage-statistics.md)
- [Volume Management](js-apis-volumemanager.md) - [Volume Management](js-apis-volumemanager.md)
- Account Management - Account Management
- [OS Account Management](js-apis-osAccount.md)
- [Distributed Account Management](js-apis-distributed-account.md) - [Distributed Account Management](js-apis-distributed-account.md)
- [App Account Management](js-apis-appAccount.md) - [App Account Management](js-apis-appAccount.md)
- Telephony Service - Telephony Service
......
# OS Account Management
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import account_osAccount from '@ohos.account.osAccount';
```
## System Capabilities
SystemCapability.Account.OsAccount
## account_osAccount.getAccountManager
getAccountManager(): AccountManager
Obtains an **AccountManager** instance.
- Return value
| Type| Description|
| -------- | -------- |
| [AccountManager](#accountmanager) | **AccountManager** instance obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
```
## OsAccountType
Enumerates OS account types.
| Name| Default Value| Description|
| -------- | -------- | -------- |
| ADMIN | 0 | Administrator account|
| NORMAL | 1 | Normal account|
| GUEST | 2 | Guest account|
## AccountManager
Provides methods to manage OS accounts.
### activateOsAccount
activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
Activates an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | -------------------- |
| localId | number | Yes | ID of the OS account to activate.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result.|
- Example
Activate OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.activateOsAccount(localId, (err)=>{
console.log("activateOsAccount err:" + JSON.stringify(err));
});
```
### activateOsAccount
activateOsAccount(localId: number): Promise&lt;void&gt;
Activates an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the OS account to activate.|
- Return value
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example
Activate OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.activateOsAccount(localId).then(() => {
console.log("activateOsAccount success");
}).catch((err) => {
console.log("activateOsAccount err:" + JSON.stringify(err));
});
```
### isMultiOsAccountEnable
isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether multiple OS accounts are supported. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable((err, isEnabled) => {
console.log("isMultiOsAccountEnable err: " + JSON.stringify(err));
console.log('isMultiOsAccountEnable isEnabled: ' + isEnabled);
});
```
### isMultiOsAccountEnable
isMultiOsAccountEnable(): Promise&lt;boolean&gt;
Checks whether multiple OS accounts are supported. This method uses a promise to return the result.
- Return value
| Type | Description |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If multiple OS accounts are supported, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isMultiOsAccountEnable().then((isEnabled) => {
console.log('isMultiOsAccountEnable, isEnabled: ' + isEnabled);
}).catch((err) => {
console.log("isMultiOsAccountEnable err: " + JSON.stringify(err));
});
```
### isOsAccountActived
isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether an OS account is activated. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|
- Example
Check whether OS account 100 is activated.
```
const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId, (err, isActive)=>{
console.log("isOsAccountActived err:" + JSON.stringify(err));
console.log("isOsAccountActived isActive:" + isActive);
});
```
### isOsAccountActived
isOsAccountActived(localId: number): Promise&lt;boolean&gt;
Checks whether an OS account is activated. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value
| Type | Description |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account is activated, **true** will be returned. Otherwise, **false** will be returned.|
- Example
Check whether OS account 100 is activated.
```
const accountManager = account_osAccount.getAccountManager();
var osLocalId = 100;
accountManager.isOsAccountActived(osLocalId).then((isActive) => {
console.log('isOsAccountActived, isActive: ' + isActive);
}).catch((err) => {
console.log("isOsAccountActived err: " + JSON.stringify(err));
});
```
### isOsAccountConstraintEnable
isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether the specified constraint is enabled for an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ---------------------- | ---- | ------------------------------ |
| localId | number | Yes | ID of the target OS account.|
| [constraint](#constraints) | string | Yes | Constraint specified.|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
- Example
Check whether OS account 100 is forbidden to use Wi-Fi.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi", (err, isConstraintEnabled)=>{
console.log("isOsAccountConstraintEnable err:" + JSON.stringify(err));
console.log("isOsAccountConstraintEnable isConstraintEnabled:" + isConstraintEnabled);
});
```
### isOsAccountConstraintEnable
isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boolean&gt;
Checks whether the specified constraint is enabled for an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | ---------------- |
| localId | number | Yes | ID of the target OS account.|
| [constraint](#constraints)| string | Yes | Constraint specified.|
- Return value
| Type | Description |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the constraint is enabled for the OS account, **true** will be returned. Otherwise, **false** will be returned.|
- Example
Check whether OS account 100 is forbidden to use Wi-Fi.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.isOsAccountConstraintEnable(localId, "constraint.wifi").then((isConstraintEnabled) => {
console.log('isOsAccountConstraintEnable, isConstraintEnabled: ' + isConstraintEnabled);
}).catch((err) => {
console.log("isOsAccountConstraintEnable err: " + JSON.stringify(err));
});
```
### isTestOsAccount
isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this OS account is a test account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount((err, isTest) => {
console.log("isTestOsAccount err: " + JSON.stringify(err));
console.log('isTestOsAccount isTest: ' + isTest);
});
```
### isTestOsAccount
isTestOsAccount(): Promise&lt;boolean&gt;
Checks whether this OS account is a test account. This method uses a promise to return the result.
- Return value
| Type | Description |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the account is a test account, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isTestOsAccount().then((isTest) => {
console.log('isTestOsAccount, isTest: ' + isTest);
}).catch((err) => {
console.log("isTestOsAccount err: " + JSON.stringify(err));
});
```
### isOsAccountVerified
isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether this OS account has been verified. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err));
console.log('isOsAccountVerified isVerified: ' + isVerified);
});
```
### isOsAccountVerified
isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether an OS account has been verified. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | ---------------------------------- |
| localId | number | No | ID of the target OS account. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified((err, isVerified) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err));
console.log('isOsAccountVerified isVerified: ' + isVerified);
});
```
### isOsAccountVerified
isOsAccountVerified(localId: number?): Promise&lt;boolean&gt;
Checks whether an OS account has been verified. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | No | ID of the target OS account.|
- Return value
| Type | Description |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. If the OS account has been verified, **true** will be returned. Otherwise, **false** will be returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.isOsAccountVerified().then((isVerified) => {
console.log('isOsAccountVerified, isVerified: ' + isVerified);
}).catch((err) => {
console.log("isOsAccountVerified err: " + JSON.stringify(err));
});
```
### removeOsAccount
removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
Removes an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the OS account to remove. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId;
)};
accountManager.removeOsAccount(createIocalId, (err)=>{
console.log("removeOsAccount err:" + JSON.stringify(err));
});
```
### removeOsAccount
removeOsAccount(localId: number): Promise&lt;void&gt;
Removes an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the OS account to remove.|
- Return value
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
var createIocalId;
osAccountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
createIocalId = osAccountInfo.localId;
)};
createIocalId = osAccount.localId;
accountManager.removeOsAccount(createIocalId).then(() => {
console.log('removeOsAccount Success');
}).catch(() => {
console.log("removeOsAccount err: " + JSON.stringify(err));
});
```
### setOsAccountConstraints
setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void
Sets or removes constraints for an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ----------- | ------------------- | ---- | ------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| [constraints](constraints)| Array&lt;string&gt; | Yes | List of constraints to set or remove. |
| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example
Disable Wi-Fi for OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.wifi"], true, (err)=>{
console.log("setOsAccountConstraints err:" + JSON.stringify(err));
});
```
### setOsAccountConstraints
setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt;
Sets or removes constraints for an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ----------- | ------------- | ---- | ----------------------- |
| localId | number | Yes | ID of the target OS account. |
| [constraints](constraints)| Array&lt;string&gt; | Yes | List of constraints to set or remove.|
| enable | boolean | Yes | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.|
- Return value
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example
Remove the constraint on Wi-Fi for OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.setOsAccountConstraints(localId, ["constraint.location.set"], false).then(() => {
console.log('setOsAccountConstraints Success');
}).catch((err) => {
console.log("setOsAccountConstraints err: " + JSON.stringify(err));
});
```
### setOsAccountName
setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;void&gt;): void
Sets a name for an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| :-------- | ------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | Account name to set. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example
Set the name of OS account 100 to **demoName**.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var newName = "demoName";
accountManager.setOsAccountName(localId, newName, (err)=>{
console.debug("setOsAccountName err:" + JSON.stringify(err));
});
```
### setOsAccountName
setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
Sets a name for an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | ----------------------- |
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | Account name to set.|
- Return value
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example
Set the name of OS account 100 to **demoName**.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var nameLimit = "demoName";
accountManager.setOsAccountName(localId, nameLimit).then(() => {
console.log('setOsAccountName Success');
}).catch((err) => {
console.log("setOsAccountName err: " + JSON.stringify(err));
});
```
### getCreatedOsAccountsCount
getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
Obtains the number of OS accounts created. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------ |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the number of OS accounts created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount((err, accountCnt)=>{
console.log("obtains the number of all os accounts created err:" + JSON.stringify(err));
console.log("obtains the number of all os accounts created accountCnt:" + accountCnt);
});
```
### getCreatedOsAccountsCount
getCreatedOsAccountsCount(): Promise&lt;number&gt;
Obtains the number of OS accounts created. This method uses a promise to return the result.
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the number of OS accounts created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getCreatedOsAccountsCount().then((accountCnt) => {
console.log('getCreatedOsAccountsCount, accountCnt: ' + accountCnt);
}).catch((err) => {
console.log("getCreatedOsAccountsCount err: " + JSON.stringify(err));
});
```
### getOsAccountLocalIdFromProcess
getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
Obtains the ID of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ----------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the account ID obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess((err, accountID) => {
console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err));
console.log('getOsAccountLocalIdFromProcess accountID: ' + accountID);
});
```
### getOsAccountLocalIdFromProcess
getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
Obtains the ID of the OS account to which the current process belongs. This method uses a promise to return the result.
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the account ID obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromProcess().then((accountID) => {
console.log('getOsAccountLocalIdFromProcess, accountID: ' + accountID);
}).catch((err) => {
console.log("getOsAccountLocalIdFromProcess err: " + JSON.stringify(err));
});
```
### getOsAccountLocalIdFromUid
getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
Obtains the OS account ID based on the process UID. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | --------------------------------------- |
| uid | number | Yes | Process UID.|
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the OS account ID obtained.|
- Example
Obtain the ID of the OS account whose process UID is **12345678**.
```
const accountManager = account_osAccount.getAccountManager();
let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid, (err, accountID) => {
console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err));
console.log('getOsAccountLocalIdFromUid: ' + accountID);
});
```
### getOsAccountLocalIdFromUid
getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
Obtains the OS account ID based on the process UID. This method uses a promise to return the result.
- Parameters
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------- |
| uid | number | Yes | Process UID.|
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the OS account ID obtained.|
- Example
Obtain the ID of the OS account whose process UID is **12345678**.
```
const accountManager = account_osAccount.getAccountManager();
let uid = 12345678;
accountManager.getOsAccountLocalIdFromUid(uid).then((accountID) => {
console.log('getOsAccountLocalIdFromUid: ' + accountID);
}).catch((err) => {
console.log("getOsAccountLocalIdFromUid err: " + JSON.stringify(err));
});
```
### getOsAccountLocalIdFromDomain
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
Obtains the OS account ID based on domain account information. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | --------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the ID of the OS account associated with the domain account.|
- Example
```
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountLocalIdFromDomain(domainInfo, (err, accountID) => {
console.log("getOsAccountLocalIdFromDomain: " + JSON.stringify(err));
console.log('getOsAccountLocalIdFromDomain: ' + accountID);
});
```
### getOsAccountLocalIdFromDomain
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
Obtains the OS account ID based on domain account information. This method uses a promise to return the result.
- Parameters
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.|
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the ID of the OS account associated with the domain account.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.getOsAccountLocalIdFromDomain(domainInfo).then((accountID) => {
console.log('getOsAccountLocalIdFromDomain: ' + accountID);
}).catch((err) => {
console.log("getOsAccountLocalIdFromDomain err: " + JSON.stringify(err));
});
```
### queryMaxOsAccountNumber
queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
Obtains the maximum number of OS accounts that can be created. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the maximum number of OS accounts that can be created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber((err, maxCnt)=>{
console.log("queryMaxOsAccountNumber err:" + JSON.stringify(err));
console.log("queryMaxOsAccountNumber maxCnt:" + maxCnt);
});
```
### queryMaxOsAccountNumber
queryMaxOsAccountNumber(): Promise&lt;number&gt;
Obtains the maximum number of OS accounts that can be created. This method uses a promise to return the result.
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the maximum number of OS accounts that can be created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryMaxOsAccountNumber().then((maxCnt) => {
console.log('queryMaxOsAccountNumber, maxCnt: ' + maxCnt);
}).catch((err) => {
console.log("queryMaxOsAccountNumber err: " + JSON.stringify(err));
});
```
### getOsAccountAllConstraints
getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
Obtains all constraints of an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------- |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | Yes | Callback used to return all constraints obtained.|
- Example
Obtain all constraints of OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountAllConstraints(localId, (err, constraints)=>{
console.log("getOsAccountAllConstraints err:" + JSON.stringify(err));
console.log("getOsAccountAllConstraints:" + JSON.stringify(constraints));
});
```
### getOsAccountAllConstraints
getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
Obtains all constraints of an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value
| Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return the constraints obtained.|
- Example
Obtain all constraints of OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountAllConstraints(localId).then((constraints) => {
console.log("getOsAccountAllConstraints, constraints: " + constraints);
}).catch((err) => {
console.log("getOsAccountAllConstraints err: " + JSON.stringify(err));
});
```
### queryAllCreatedOsAccounts
queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&gt;): void
Obtains information about all the OS accounts created. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Yes | Callback used to return information about OS accounts created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts((err, accountArr)=>{
console.log("queryAllCreatedOsAccounts err:" + JSON.stringify(err));
console.log("queryAllCreatedOsAccounts accountArr:" + JSON.stringify(accountArr));
});
```
### queryAllCreatedOsAccounts
queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
Obtains information about all the OS accounts created. This method uses a promise to return the result.
- Return value
| Type | Description |
| :---------------------------- | :---------------------------------- |
| Promise&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Promise used to return information about OS accounts created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryAllCreatedOsAccounts().then((accountArr) => {
console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
}).catch((err) => {
console.log("queryAllCreatedOsAccounts err: " + JSON.stringify(err));
});
```
### queryActivatedOsAccountIds
queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Obtains information about all activated OS accounts. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return information about activated OS accounts.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds((err, idArray)=>{
console.log("queryActivatedOsAccountIds err:" + JSON.stringify(err));
console.log("queryActivatedOsAccountIds idArray length:" + idArray.length);
for(var i=0;i<idArray.length;i++) {
console.info("activated os account id: " + idArray[i]);
}
});
```
### queryActivatedOsAccountIds
queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
Obtains information about all activated OS accounts. This method uses a promise to return the result.
- Return value
| Type | Description |
| :---------------------------- | :---------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise used to return information about activated OS accounts.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryActivatedOsAccountIds().then((idArray) => {
console.log('queryActivatedOsAccountIds, idArray: ' + idArray);
}).catch((err) => {
console.log("queryActivatedOsAccountIds err: " + JSON.stringify(err));
});
```
### createOsAccount
createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Creates an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| :-------- | ---------------------------- | ---- | -------------------- |
| localName | string | Yes | Name of the OS account to create. |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testName", osaccount.OsAccountType.NORMAL, (err, osAccountInfo)=>{
console.log("createOsAccount err:" + JSON.stringify(err));
console.log("createOsAccount osAccountInfo:" + JSON.stringify(osAccountInfo));
});
```
### createOsAccount
createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInfo&gt;
Creates an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| --------- | ------------- | ---- | ---------------- |
| localName | string | Yes | Name of the OS account to create.|
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.|
- Return value
| Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.createOsAccount("testAccountName", osaccount.OsAccountType.NORMAL).then((accountInfo) => {
console.log("createOsAccount, accountInfo: " + JSON.stringify(accountInfo));
}).catch((err) => {
console.log("createOsAccount err: " + JSON.stringify(err));
});
```
### createOsAccountForDomain
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Creates an OS account and associates it with the specified domain account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| :-------- | ---------------------------- | ---- | -------------------- |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information. |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo, (err, osAccountInfo)=>{
console.log("createOsAccountForDomain err:" + JSON.stringify(err));
console.log("createOsAccountForDomain osAccountInfo:" + JSON.stringify(osAccountInfo));
});
```
### createOsAccountForDomain
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt;
Creates an OS account and associates it with the specified domain account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| --------- | ------------- | ---- | ---------------- |
| type | [OsAccountType](#osaccounttype) | Yes | Type of the OS account to create.|
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | Yes | Domain account information.|
- Return value
| Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account created.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
accountManager.createOsAccountForDomain(osaccount.OsAccountType.NORMAL, domainInfo).then((accountInfo) => {
console.log("createOsAccountForDomain, account info: " + JSON.stringify(accountInfo));
}).catch((err) => {
console.log("createOsAccountForDomain err: " + JSON.stringify(err));
});
```
### queryCurrentOsAccount
queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Obtains information about the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return information about the OS account obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount((err, curAccountInfo)=>{
console.log("queryCurrentOsAccount err:" + JSON.stringify(err));
console.log("queryCurrentOsAccount curAccountInfo:" + JSON.stringify(curAccountInfo));
});
```
### queryCurrentOsAccount
queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
Obtains information about the OS account to which the current process belongs. This method uses a promise to return the result.
- Return value
| Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return information about the OS account obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.queryCurrentOsAccount().then((accountInfo) => {
console.log("queryCurrentOsAccount, accountInfo: " + JSON.stringify(accountInfo));
}).catch((err) => {
console.log("queryCurrentOsAccount err: " + JSON.stringify(err));
});
```
### queryOsAccountById
queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
Obtains information about an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------------------- |
| localId | number | Yes | ID of the target OS account.|
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | Yes | Callback used to return the OS account information obtained.|
- Example
Query information about OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.queryOsAccountById(localId, (err, accountInfo)=>{
console.log("queryOsAccountById err:" + JSON.stringify(err));
console.log("queryOsAccountById accountInfo:" + JSON.stringify(accountInfo));
});
```
### queryOsAccountById
queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
Obtains information about an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------------------- |
| localId | number | Yes | ID of the target OS account.|
- Return value
| Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise used to return the OS account information obtained.|
- Example
Query information about OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.queryOsAccountById(localId).then((accountInfo) => {
console.log("queryOsAccountById, accountInfo: " + JSON.stringify(accountInfo));
}).catch((err) => {
console.log("queryOsAccountById err: " + JSON.stringify(err));
});
```
### getOsAccountTypeFromProcess
getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
Obtains the type of the OS account to which the current process belongs. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | Yes | Callback used to return the OS account type.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess((err, accountType) => {
console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err));
console.log('getOsAccountTypeFromProcess accountType: ' + accountType);
});
```
### getOsAccountTypeFromProcess
getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
Obtains the type of the OS account to which the current process belongs. This method uses a promise to return the result.
- Return value
| Type | Description |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise used to return the OS account type.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getOsAccountTypeFromProcess().then((accountType) => {
console.log('getOsAccountTypeFromProcess, accountType: ' + accountType);
}).catch((err) => {
console.log("getOsAccountTypeFromProcess err: " + JSON.stringify(err));
});
```
### getDistributedVirtualDeviceId
getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
Obtains the ID of this distributed virtual device. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the device ID obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId((err, virtualID) => {
console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err));
console.log('getDistributedVirtualDeviceId virtualID: ' + virtualID);
});
```
### getDistributedVirtualDeviceId
getDistributedVirtualDeviceId(): Promise&lt;string&gt;
Obtains the ID of this distributed virtual device. This method uses a promise to return the result.
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the device ID obtained.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
accountManager.getDistributedVirtualDeviceId().then((virtualID) => {
console.log('getDistributedVirtualDeviceId, virtualID: ' + virtualID);
}).catch((err) => {
console.log("getDistributedVirtualDeviceId err: " + JSON.stringify(err));
});
```
### getOsAccountProfilePhoto
getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;): void
Obtains the profile photo of an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the profile photo obtained.|
- Example
Obtain the profile photo of OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountProfilePhoto(localId, (err, photo)=>{
console.log("getOsAccountProfilePhoto err:" + JSON.stringify(err));
console.log("get photo:" + photo + " by localId: " + localId);
});
```
### getOsAccountProfilePhoto
getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
Obtains the profile photo of an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise used to return the profile photo obtained.|
- Example
Obtain the profile photo of OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getOsAccountProfilePhoto(localId).then((photo) => {
console.log("getOsAccountProfilePhoto: " + photo);
}).catch((err) => {
console.log("getOsAccountProfilePhoto err: " + JSON.stringify(err));
});
```
### setOsAccountProfilePhoto
setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback&lt;void&gt;): void
Sets a profile photo for an OS account. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | ------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the target OS account. |
| photo | string | Yes | Profile photo information. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
- Example
Set a profile photo for OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
osAccountManager.setOsAccountProfilePhoto(localId, photo, (err)=>{
console.log("setOsAccountProfilePhoto err:" + JSON.stringify(err));
});
```
### setOsAccountProfilePhoto
setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
Sets a profile photo for an OS account. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
| photo | string | Yes | Profile photo information. |
- Return value
| Type | Description |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
- Example
Set a profile photo for OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
var photo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA"+
"Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y"+
"q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo"+
"+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=="
accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
console.log("setOsAccountProfilePhoto success");
}).catch((err) => {
console.log("setOsAccountProfilePhoto err: " + JSON.stringify(err));
});
```
### getOsAccountLocalIdBySerialNumber
getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
Obtains the OS account ID based on the SN. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------------ | --------------------- | ---- | ------------------------------ |
| serialNumber | number | Yes | Account SN. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the OS account ID obtained.|
- Example
Obtain the ID of the OS account whose SN is 12345.
```
const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber, (err, localId)=>{
console.log("ger localId err:" + JSON.stringify(err));
console.log("get localId:" + localId + " by serialNumber: " + serialNumber);
});
```
### getOsAccountLocalIdBySerialNumber
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
Obtains the OS account ID based on the SN. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------------ | ------ | ---- | ---------- |
| serialNumber | number | Yes | Account SN.|
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the OS account ID obtained.|
- Example
Obtain the ID of the OS account whose SN is 12345.
```
const accountManager = account_osAccount.getAccountManager();
var serialNumber = 12345;
accountManager.getOsAccountLocalIdBySerialNumber(serialNumber).then((localId) => {
console.log("getOsAccountLocalIdBySerialNumber localId: " + localId);
}).catch((err) => {
console.log("getOsAccountLocalIdBySerialNumber err: " + JSON.stringify(err));
});
```
### getSerialNumberByOsAccountLocalId
getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
Obtains the SN of an OS account based on the account ID. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ------------------------------ |
| localId | number | Yes | ID of the target OS account. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the account SN obtained.|
- Example
Obtain the SN of the OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId, (err, serialNumber)=>{
console.log("ger serialNumber err:" + JSON.stringify(err));
console.log("get serialNumber:" + serialNumber + " by localId: " + localId);
});
```
### getSerialNumberByOsAccountLocalId
getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
Obtains the SN of an OS account based on the account ID. This method uses a promise to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ------------ |
| localId | number | Yes | ID of the target OS account.|
- Return value
| Type | Description |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise used to return the account SN obtained.|
- Example
Obtain the SN of the OS account 100.
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
accountManager.getSerialNumberByOsAccountLocalId(localId).then((serialNumber) => {
console.log("getSerialNumberByOsAccountLocalId serialNumber: " + serialNumber);
}).catch((err) => {
console.log("getSerialNumberByOsAccountLocalId err: " + JSON.stringify(err));
});
```
### on
on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&gt;): void
Subscribes to OS account changes. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ------------------------ |
| type | 'activate' \| 'activating' | Yes | Type of the event to subscribe to. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated. |
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes.|
| callback | Callback&lt;number&gt; | Yes | Callback used to return the OS account ID and status changes.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
function onCallback(receiveLocalId){
console.log("receive localId:" + receiveLocalId);
}
accountManager.on("activating", "osAccountOnOffNameA", onCallback);
```
### off
off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number&gt;): void
Unsubscribes from the OS account changes. This method uses an asynchronous callback to return the result.
- Parameters
| Name | Type | Mandatory| Description |
| -------- | -------------------------- | ---- | ---------------------------- |
| type | 'activate' \| 'activating' | Yes | Type of the event to unsubscribe from. The value **activate** means an event indicating that an OS account is activated, and **activating** means an event indicating that an OS account is being activated. |
| name | string | Yes | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.|
| callback | Callback&lt;number&gt; | No | Callback used to return the OS account changes. By default, **0** is returned.|
- Example
```
const accountManager = account_osAccount.getAccountManager();
function offCallback(){
console.log("off enter")
}
accountManager.off("activating", "osAccountOnOffNameA", offCallback);
```
## OsAccountInfo
Defines information about an OS account.
| Name | Type | Mandatory| Description |
| ----------------- | ---------------------------------- | ---- | ------------------------ |
| localId | number | Yes | ID of the target OS account. |
| localName | string | Yes | OS account name. |
| type | [OsAccountType](#osaccounttype) | Yes | OS account type. |
| [constraints](constraints) | Array&lt;string&gt; | No | Constraints on the OS account. |
| isVerified | boolean | Yes | Whether the OS account is verified. |
| photo | string | No | Profile photo of the OS account. |
| createTime | number | Yes | Time when the OS account was created. |
| lastLoginTime | number | No | Last login time of the OS account.|
| serialNumber | number | Yes | SN of the OS account. |
| isActived | boolean | Yes | Whether the OS account is activated. |
| isCreateCompleted | boolean | Yes | Whether the OS account information is complete. |
| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | No | Distributed account information. |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | No | Domain account information. |
## DomainAccountInfo
Defines the domain account information.
| Name | Type | Mandatory| Description |
| ----------------- | ---------------------------------- | ---- | ------------------------ |
| domain | string | Yes | Domain name. |
| accountName | string | Yes | Domain account name. |
## Constraints
| Constraint| Description|
| ----------------- | ------------------- |
| constraint.wifi | A user is not allowed to use Wi-Fi.|
| constraint.wifi.set | A user is not allowed to change Wi-Fi settings.|
| constraint.locale.set | A user is not allowed to change the device language.|
| constraint.app.accounts | A user is not allowed to add or delete app accounts.|
| constraint.apps.install | A user is not allowed to install apps.|
| constraint.apps.uninstall | A user is not allowed to uninstall apps.|
| constraint.location.shared | A user is not allowed to enable location sharing.|
| constraint.unknown.sources.install | A user is not allowed to install apps from unknown sources.|
| constraint.global.unknown.app.install | All users are not allowed to install apps from unknown sources.|
| constraint.bluetooth.set | A user is not allowed to configure Bluetooth.|
| constraint.bluetooth | The use of Bluetooth is prohibited on the device.
| constraint.bluetooth.share | Bluetooth sharing is prohibited.|
| constraint.usb.file.transfer | A user is not allowed to transfer files over USB.|
| constraint.credentials.set | A user is not allowed to configure user credentials.|
| constraint.os.account.remove | An admin user is not allowed to remove users or a non-admin user is not allowed to remove itself.|
| constraint.managed.profile.remove | The managed profiles of this user cannot be removed.|
| constraint.debug.features.use | A user is not allowed to enable or access debugging features.|
| constraint.vpn.set | A user is not allowed to configure a VPN.|
| constraint.date.time.set | A user is not allowed to set date, time, or time zone.|
| constraint.tethering.config | A user is not allowed to configure Tethering.|
| constraint.network.reset | A user is not allowed to reset network settings.|
| constraint.factory.reset | A user is not allowed to reset factory settings.|
| constraint.os.account.create | A user is not allowed to create users.|
| constraint.add.managed.profile | A user is not allowed to add managed profiles.|
| constraint.apps.verify.disable | A user is not allowed to disable app verification.|
| constraint.cell.broadcasts.set | A user is not allowed to configure cell broadcasts.|
| constraint.mobile.networks.set | A user is not allowed to configure radio networks.|
| constraint.control.apps | A user is not allowed to modify apps in **Settings** or the boot module.|
| constraint.physical.media | A user is not allowed to mount external physical media.|
| constraint.microphone | A user is not allowed to use microphones.|
| constraint.microphone.unmute | A user is not allowed to adjust the microphone volume.|
| constraint.volume.adjust | A user is not allowed to adjust the device's global volume.|
| constraint.calls.outgoing | A user is not allowed to make outgoing calls.|
| constraint.sms.use | A user is not allowed to send or receive SMS messages.|
| constraint.fun | A user is not allowed to have entertainment.|
| constraint.windows.create | Windows other than app windows cannot be created.|
| constraint.system.error.dialogs | Error dialogs for crashed or unresponsive apps are prohibited.|
| constraint.cross.profile.copy.paste | Pasting clipboard content to other users or profiles is prohibited.|
| constraint.beam.outgoing | A user is not allowed to use Near Field Communications (NFC) to transfer data from apps.|
| constraint.wallpaper | A user is not allowed to manage wallpapers.|
| constraint.safe.boot | A user is not allowed to reboot the device in safe boot mode.|
| constraint.parent.profile.app.linking | The apps in the parent profile are allowed to handle web links from the managed profile.|
| constraint.audio.record | Audio recording is prohibited.|
| constraint.camera.use | The use of cameras is prohibited.|
| constraint.os.account.background.run | Running in the background is prohibited.|
| constraint.data.roam | A user is not allowed to use cellular data when roaming.|
| constraint.os.account.set.icon | A user is not allowed to change their icon.|
| constraint.wallpaper.set | A user is not allowed to set a wallpaper.|
| constraint.oem.unlock | A user is not allowed to enable OEM unlock.|
| constraint.device.unmute | A user is not allowed to mute the device's global volume.|
| constraint.password.unified | The managed profile is not allowed to have unified lock screen challenge with the primary user.|
| constraint.autofill | A user is not allowed to use the autofill service.|
| constraint.content.capture | Capturing the content of a user's screen is prohibited.|
| constraint.content.suggestions | A user is not allowed to receive content suggestions.|
| constraint.os.account.start | User switching is blocked.|
| constraint.location.set | A user is not allowed to configure the location service.|
| constraint.airplane.mode.set | The airplane mode is prohibited on the device.|
| constraint.brightness.set | A user is not allowed to configure brightness.|
| constraint.share.into.profile | A user is not allowed to share files, images, or data from the primary user to the managed profile.|
| constraint.ambient.display | Ambient display is prohibited for the user.|
| constraint.screen.timeout.set | A user is not allowed to configure the screen off timeout.|
| constraint.print | A user is not allowed to print.|
| constraint.private.dns.set | A user is not allowed to configure a private domain name server (DNS).|
...@@ -9,11 +9,11 @@ On the basis of the SQLite database, the RDB allows you to operate data with or ...@@ -9,11 +9,11 @@ On the basis of the SQLite database, the RDB allows you to operate data with or
The following table describes APIs available for creating and deleting an RDB store. The following table describes APIs available for creating and deleting an RDB store.
Table 1 APIs for creating and deleting an RDB store **Table 1** APIs for creating and deleting an RDB store
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbStoreConfig | RdbStoreConfig(const std::string &path, <br> StorageMode storageMode = StorageMode::MODE_DISK, <br> bool readOnly = false, <br> const std::vector<uint8_t> &encryptKey = std::vector<uint8_t>(), <br> const std::string &journalMode = "", <br> const std::string &syncMode = "", <br> const std::string &databaseFileType = "", <br> const std::string &databaseFileSecurityLevel = "") | Configures an RDB store, including setting the name, storage mode, log mode, synchronization mode, and read-only mode, and encrypting the database. <ul><li> **path**: path of the database. </li> <li> **readOnly**: whether the database is read-only. </li> <li> **storageMode**: storage mode. </li> <li> **encryptKey**: key used for database encryption. </li> <li> **journalMode**: database logging mode. </li> <li> **syncMode**: data synchronization mode. </li> <li> **databaseFileType**: database type. </li> <li> **databaseFileSecurityLevel**: security level. </li></ul>| | RdbStoreConfig | RdbStoreConfig(const std::string &path, <br> StorageMode storageMode = StorageMode::MODE_DISK, <br> bool readOnly = false, <br> const std::vector<uint8_t> &encryptKey = std::vector<uint8_t>(), <br> const std::string &journalMode = "", <br> const std::string &syncMode = "", <br> const std::string &databaseFileType = "", <br> const std::string &databaseFileSecurityLevel = "") | Configures an RDB store, including setting the name, storage mode, log mode, synchronization mode, and read-only mode, and encrypting the RDB store.<br/> -&nbsp;**path**: path of the database.<br/> -&nbsp;**readOnly**: whether the database is read-only.<br/> -&nbsp; **storageMode**: storage mode.<br/> -&nbsp;**encryptKey**: key used for database encryption.<br/> -&nbsp;**journalMode**: database logging mode.<br/> -&nbsp;**syncMode**: data synchronization mode.<br/> -&nbsp;**databaseFileType**: database type.<br/> -&nbsp;**databaseFileSecurityLevel**: security level. |
| RdbOpenCallback | int OnCreate(RdbStore &rdbStore) | Called when an RDB store is created. You can add the method for initializing the table structure and add initialization data used by your application in the callback.| | RdbOpenCallback | int OnCreate(RdbStore &rdbStore) | Called when an RDB store is created. You can add the method for initializing the table structure and add initialization data used by your application in the callback.|
| RdbOpenCallback | int OnUpgrade(RdbStore &rdbStore, int currentVersion, int targetVersion) | Called when the RDB store is upgraded.| | RdbOpenCallback | int OnUpgrade(RdbStore &rdbStore, int currentVersion, int targetVersion) | Called when the RDB store is upgraded.|
| RdbOpenCallback | int OnDowngrade(RdbStore &rdbStore, int currentVersion, int targetVersion) | Called when the RDB store is downgraded.| | RdbOpenCallback | int OnDowngrade(RdbStore &rdbStore, int currentVersion, int targetVersion) | Called when the RDB store is downgraded.|
...@@ -22,12 +22,12 @@ Table 1 APIs for creating and deleting an RDB store ...@@ -22,12 +22,12 @@ Table 1 APIs for creating and deleting an RDB store
### Encrypting an RDB Store ### Encrypting an RDB Store
The RDB provides the database encryption capability. When creating an RDB store , you can add a key for security purposes. After that, the RDB store can be accessed only with the correct key. The RDB provides the database encryption capability. When creating an RDB store, you can add a key for security purposes. After that, the RDB store can be accessed only with the correct key.
Table 2 API for changing the key **Table 2** API for changing the key
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbStore | int ChangeEncryptKey(const std::vector<uint8_t> &newKey) | Changes the encryption key for an RDB store. <br>Note: The encryption key can be changed only for an encrypted database.| | RdbStore | int ChangeEncryptKey(const std::vector<uint8_t> &newKey) | Changes the encryption key for an RDB store. <br>Note: The encryption key can be changed only for an encrypted RDB store.|
### Using Predicates ### Using Predicates
...@@ -36,7 +36,7 @@ The RDB provides **AbsRdbPredicates** for you to set database operation conditio ...@@ -36,7 +36,7 @@ The RDB provides **AbsRdbPredicates** for you to set database operation conditio
- **RdbPredicates**: With this class, you do not need to write complex SQL statements. Instead, you can combine SQL statements simply by calling methods in this class, such as **equalTo**, **notEqualTo**, **groupBy**, **orderByAsc**, and **beginsWith**. - **RdbPredicates**: With this class, you do not need to write complex SQL statements. Instead, you can combine SQL statements simply by calling methods in this class, such as **equalTo**, **notEqualTo**, **groupBy**, **orderByAsc**, and **beginsWith**.
- **RawRdbPredicates**: With this class, you can set **whereClause** and **whereArgs**, but cannot call methods such as **equalTo**. - **RawRdbPredicates**: With this class, you can set **whereClause** and **whereArgs**, but cannot call methods such as **equalTo**.
Table 7 APIs for RDB predicates **Table 3** APIs for RDB store predicates
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbPredicates | AbsPredicates *EqualTo(std::string field, std::string value) | Sets the **AbsPredicates** to match the field that is equal to the specified value.| | RdbPredicates | AbsPredicates *EqualTo(std::string field, std::string value) | Sets the **AbsPredicates** to match the field that is equal to the specified value.|
...@@ -46,6 +46,9 @@ The RDB provides **AbsRdbPredicates** for you to set database operation conditio ...@@ -46,6 +46,9 @@ The RDB provides **AbsRdbPredicates** for you to set database operation conditio
| RdbPredicates | AbsPredicates *OrderByAsc(std::string field) | Sets the **AbsPredicates** to match the column with values sorted in ascending order.| | RdbPredicates | AbsPredicates *OrderByAsc(std::string field) | Sets the **AbsPredicates** to match the column with values sorted in ascending order.|
| RdbPredicates | void SetWhereClause(std::string whereClause) | Sets **whereClause**.| | RdbPredicates | void SetWhereClause(std::string whereClause) | Sets **whereClause**.|
| RdbPredicates | void SetWhereArgs(std::vector\<std::string\> whereArgs) | Sets **whereArgs**, which indicates the value of the placeholder in **whereClause**.| | RdbPredicates | void SetWhereArgs(std::vector\<std::string\> whereArgs) | Sets **whereArgs**, which indicates the value of the placeholder in **whereClause**.|
| RdbPredicates | AbsRdbPredicates *InDevices(std::vector<std::string>& devices) | Sets the **AbsPredicates** to specify the remote devices on the network with databases to be synchronized.|
| RdbPredicates | AbsRdbPredicates *InAllDevices() | Sets the **AbsPredicates** to connect to all remote devices on the network when synchronizing distributed databases.|
### Managing Data in an RDB Store ### Managing Data in an RDB Store
...@@ -55,29 +58,29 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th ...@@ -55,29 +58,29 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
The RDB provides an API for inserting data through **ValuesBucket** in a data table. If the data is added, the row number of the data inserted is returned; otherwise, **-1** is returned. The RDB provides an API for inserting data through **ValuesBucket** in a data table. If the data is added, the row number of the data inserted is returned; otherwise, **-1** is returned.
Table 3 API for inserting data to a data table **Table 4** APIs for inserting data tables
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbStore | int Insert(int64_t &outRowId, const std::string &table, const ValuesBucket &initialValues) | Inserts data based on the passed table name and data in **ValuesBucket**. <ul><li>**table**: specifies the name of the target table. </li><li> **initialValues**: specifies the data, stored in **ValuesBucket**, to insert. A series of **put()** methods, such as **PutString(const std::string &columnName, const std::string &value)** and **PutDouble(const std::string &columnName, double value)**, are provided to add data to **ValuesBucket**.</li></ul> | | RdbStore | int Insert(int64_t &outRowId, const std::string &table, const ValuesBucket &initialValues) | Inserts data based on the passed table name and data in **ValuesBucket**. <br/>-&nbsp;**table**: specifies the name of the target table.<br/> -&nbsp;**initialValues**: specifies the data, stored in **ValuesBucket**, to insert. A series of **put()** methods, such as **PutString(const std::string &columnName, const std::string &value)** and **PutDouble(const std::string &columnName, double value)**, are provided to add data to **ValuesBucket**. |
- Deleting data - Deleting data
Call the **delete()** method to delete data meeting the conditions specified by **AbsRdbPredicates**. If the data is deleted, the row number of the deleted data is returned; otherwise, **0** is returned. Call the **delete()** method to delete data meeting the conditions specified by **AbsRdbPredicates**. If the data is deleted, the row number of the deleted data is returned; otherwise, **0** is returned.
Table 5 API for deleting data **Table 5** API for deleting data
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbStore | int Delete(int &deletedRows, const AbsRdbPredicates &predicates) | Deletes data. <ul><li> **deletedRows**: specifies the number of rows to delete. </li><li> **predicates**: specifies the table name and conditions for deleting the data. **AbsRdbPredicates** has the following classes: <ul><li> **RdbPredicates**: specifies delete conditions by calling its methods, such as **equalTo**. </li><li> **RawRdbPredicates**: specifies the table name, **whereClause** and **whereArgs** only. </li></ul></li></ul> | | RdbStore | int Delete(int &deletedRows, const AbsRdbPredicates &predicates) | Deletes data. <br/>-&nbsp;**deletedRows**: specifies the number of rows to delete.<br/> -&nbsp;**predicates**: specifies the table name and conditions for deleting the data.<br/> **AbsRdbPredicates** has the following classes:<br/> -&nbsp;**RdbPredicates**: specifies update conditions by calling its methods, such as **equalTo**.<br/> -&nbsp;**RawRdbPredicates**: specifies the table name, **whereClause** and **whereArgs** only. |
- Updating data - Updating data
Call the **update()** method to modify data based on the passed data and the conditions specified by **AbsRdbPredicates**. If the data is updated, the row number of the updated data is returned; otherwise, **0** is returned. Call the **update()** method to modify data based on the passed data and the conditions specified by **AbsRdbPredicates**. If the data is updated, the row number of the updated data is returned; otherwise, **0** is returned.
Table 4 API for updating data **Table 6** API for updating data
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbStore | int Update(int &changedRows, const ValuesBucket &values, const AbsRdbPredicates &predicates) | Updates the data that meets the conditions specified by predicates. <ul><li> **changedRows**: specifies the number of rows to update. </li><li> **values**: specifies the new data stored in **ValuesBucket**. </li><li> **predicates**: specifies the table name and conditions for the update operation. **AbsRdbPredicates** has the following classes: <ul><li> **RdbPredicates**: specifies update conditions by calling its methods, such as **equalTo**. </li><li> **RawRdbPredicates**: specifies the table name, **whereClause** and **whereArgs** only. </li></ul></li></ul> | | RdbStore | int Update(int &changedRows, const ValuesBucket &values, const AbsRdbPredicates &predicates) | Updates the data that meets the conditions specified by predicates.<br/> -&nbsp;**changedRows**: specifies the number of rows to update.<br/> -&nbsp;**values**: specifies the new data stored in **ValuesBucket**.<br/> -&nbsp;**predicates**: specifies the table name and conditions for the update operation. **AbsRdbPredicates** has the following classes: <br/>-&nbsp;**RdbPredicates**: specifies update conditions by calling its methods, such as **equalTo**.<br/> -&nbsp;**RawRdbPredicates**: specifies the table name, **whereClause** and **whereArgs** only. |
- Querying data - Querying data
...@@ -86,32 +89,75 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th ...@@ -86,32 +89,75 @@ The RDB provides APIs for inserting, deleting, updating, and querying data in th
- Call the **query()** method to query data based on the predicates, without passing any SQL statement. - Call the **query()** method to query data based on the predicates, without passing any SQL statement.
- Run the native SQL statement. - Run the native SQL statement.
Table 6 APIs for querying data **Table 7** APIs for querying data
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| RdbStore | std::unique_ptr<AbsSharedResultSet> Query(const AbsRdbPredicates &predicates, const std::vector\<std::string\> columns) | Queries data. <ul><li> **predicates**: specifies the query conditions. **AbsRdbPredicates** has the following classes: <ul><li> **RdbPredicates**: specifies the query conditions by calling its methods, such as **equalTo**. </li><li> **RawRdbPredicates**: specifies the table name, **whereClause**, and **whereArgs** only. </li></ul> <li> **columns**: specifies the number of columns returned.</li></ul></li></ul> | | RdbStore | std::unique_ptr<AbsSharedResultSet> Query(const AbsRdbPredicates &predicates, const std::vector\<std::string\> columns) | Queries data. <br/>-&nbsp;**predicates**: specifies the query conditions. **AbsRdbPredicates** has the following classes: <br/>-&nbsp;**RdbPredicates**: specifies update conditions by calling its methods, such as **equalTo**. <br/>-&nbsp;**RawRdbPredicates**: specifies the table name, **whereClause**, and **whereArgs** only. <br/>-&nbsp;**columns**: specifies the number of columns returned. |
| RdbStore | std::unique_ptr<AbsSharedResultSet> QuerySql(const std::string &sql, const std::vector\<std::string\> &selectionArgs = std::vector\<std::string\>()) | Executes the native SQL statements to query data. <ul><li> **sql**: specifies the native SQL statement. </li><li> **selectionArgs**: specifies the parameter values corresponding to the placeholders in the SQL statements. Set it to **null** if the **select** statement has no placeholder.</li></ul> | | RdbStore | std::unique_ptr<AbsSharedResultSet> QuerySql(const std::string &sql, const std::vector\<std::string\> &selectionArgs = std::vector\<std::string\>()) | Executes the native SQL statements to query data. <br/>-&nbsp;**sql**: specifies the native SQL statement. <br/>-&nbsp;**selectionArgs**: specifies the parameter values corresponding to the placeholders in the SQL statements. Set it to **null** if the **select** statement has no placeholder. |
### Using the Result Set ### Using the Result Set
A result set can be regarded as rows of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**. A result set can be regarded as rows of data in the queried results. It allows you to traverse and access the data you have queried. The following table describes the external APIs of **ResultSet**.
Table 8 APIs for using the result set **Table 8** APIs for using the result set
| Class| API| Description| | Class| API| Description|
| ---- | ---- | ---- | | ---- | ---- | ---- |
| ResultSet | int GoTo(int offset) | Moves the result set forwards or backwards by the specified offset relative to its current position.| | ResultSet | int GoTo(int offset) | Moves the result set forwards or backwards by the specified offset relative to its current position.|
| ResultSet | int GoToRow(int position) | Moves the result set to the specified row.| | ResultSet | int GoToRow(int position) | Moves the result set to the specified row.|
| ResultSet | int GoToNextRow() | Moves the result set to the next row.| | ResultSet | int GoToNextRow() | Moves the result set to the next row.|
| ResultSet | int GoToPreviousRow() | Moves the result set to the previous row.| | ResultSet | int GoToPreviousRow() | Moves the result set to the previous row.|
| ResultSet | int IsStarted(bool &result) | Checks whether the result set has been moved.| | ResultSet | int IsStarted(bool &result) | Checks whether the result set has been moved.|
| ResultSet | int IsEnded(bool &result) | Checks whether the result set is moved after the last line.| | ResultSet | int IsEnded(bool &result) | Checks whether the result set is moved after the last line.|
| ResultSet | int IsAtFirstRow(bool &result) | Checks whether the result set is located in the first row.| | ResultSet | int IsAtFirstRow(bool &result) | Checks whether the result set is located in the first row.|
| ResultSet | int IsAtLastRow(bool &result) | Checks whether the result set is located in the last row.| | ResultSet | int IsAtLastRow(bool &result) | Checks whether the result set is located in the last row.|
| ResultSet | int GetRowCount(int &count) | Obtains the number of rows in the result set.| | ResultSet | int GetRowCount(int &count) | Obtains the number of rows in the result set.|
| ResultSet | int GetColumnCount(int &count) | Obtains the number of columns in the result set.| | ResultSet | int GetColumnCount(int &count) | Obtains the number of columns in the result set.|
| ResultSet | int GetString(int columnIndex, std::string &value) | Obtains the values in the specified column of the current row, in strings.| | ResultSet | int GetString(int columnIndex, std::string &value) | Obtains the values in the specified column of the current row, in strings.|
| ResultSet | int GetBlob(int columnIndex, std::vector\<uint8_t\> &blob) | Obtains the values in the specified column of the current row, in a byte array.| | ResultSet | int GetBlob(int columnIndex, std::vector\<uint8_t\> &blob) | Obtains the values in the specified column of the current row, in a byte array.|
| ResultSet | int GetDouble(int columnIndex, double &value) | Obtains the values in the specified column of the current row, in double.| | ResultSet | int GetDouble(int columnIndex, double &value) | Obtains the values in the specified column of the current row, in double.|
### Setting a List of Distributed Tables
You can set a list of distributed tables for data operations across devices.
**Table 9** API for setting a distributed table list
| Class| API| Description|
| ---- | ---- | ---- |
| RdbStore | bool SetDistributedTables(const std::vector<std::string>& tables) | Sets a list of distributed tables.<br/> -&nbsp;**tables**: specifies the names of the distributed tables to set. |
### Obtaining the Distributed Table Name for a Remote Device
When querying the RDB store of a remote device, you need to use the distributed table name. You can obtain the distributed table name of a remote device based on the local table name.
**Table 10** API for obtaining the distributed table name of a remote device
| Class| API| Description|
| ---- | ---- | ---- |
| RdbStore | std::string ObtainDistributedTableName(const std::string& device, const std::string& table) | Obtains the distributed table name of a remote device based on the local table name. The distributed table name can be used to query the RDB store of the remote device.<br> -&nbsp;**device**: specifies the ID of the remote device.<br/> -&nbsp;**table**: specifies the name of the local table. |
### Synchronizing Data Between Devices
**Table 11** API for cross-device data synchronization
| Class| API| Description|
| ---- | ---- | ---- |
| RdbStore | bool Sync(const SyncOption& option, const AbsRdbPredicates& predicate, const SyncCallback& callback) | Synchronizes data between devices.<br/> -&nbsp;**option**: specifies synchronization options, which include the following: <br/>**mode**: specifies how data is synchronized. The value **push** means to push data from the local device to the remote device; the value **pull** means to pull data from the remote device to the local device. <br/>**isBlock**: specifies whether the invocation of this function is blocked. <br/>-&nbsp;**callback**: specifies the callback used to return the result. |
### Registering an RDB Store Observer
**Table 12** API for registering an observer
| Class| API| Description|
| ---- | ---- | ---- |
| RdbStore | bool Subscribe(const SubscribeOption& option, RdbStoreObserver *observer) | Registers an observer for this RDB store to subscribe to distributed data changes. When data in the RDB store changes, a callback will be invoked to return the data changes.<br/> -&nbsp;**option**: specifies the subscription type.<br/>-&nbsp;**observer**: specifies the observer of data changes in the RDB store. |
### Unregistering an RDB Store Observer
**Table 13** API for unregistering an observer
| Class| API| Description|
| ---- | ---- | ---- |
| RdbStore | bool UnSubscribe(const SubscribeOption& option, RdbStoreObserver *observer) | Unregisters the observer of the specified type to unsubscribe from distributed data changes.<br/> -&nbsp;**option**: specifies the subscription type to unregister.<br/>-&nbsp;**observer**: specifies the observer to unregister. |
## Constraints ## Constraints
...@@ -121,7 +167,7 @@ None. ...@@ -121,7 +167,7 @@ None.
1. Create an RDB store. 1. Create an RDB store.
a. Configure the RDB store attributes, including the database name, storage mode, and read-only mode. a. Configure the RDB store attributes, including the RDB store name, storage mode, and read-only mode.
b. Initialize the table structure and related data in the RDB store. b. Initialize the table structure and related data in the RDB store.
...@@ -155,6 +201,8 @@ None. ...@@ -155,6 +201,8 @@ None.
b. Call the **insert()** method to insert data into the RDB store. b. Call the **insert()** method to insert data into the RDB store.
c. Create an RDB store.
The sample code is as follows: The sample code is as follows:
``` ```
ValuesBucket values; ValuesBucket values;
...@@ -186,3 +234,76 @@ None. ...@@ -186,3 +234,76 @@ None.
std::unique_ptr<ResultSet> resultSet = store->Query(predicates, columns) std::unique_ptr<ResultSet> resultSet = store->Query(predicates, columns)
resultSet.goToNextRow(); resultSet.goToNextRow();
``` ```
4. Set the distributed tables to be synchronized.
Call the **SetDistributedTables()** method to set the distributed tables to be synchronized.
The sample code is as follows:
```
store->SetDistributedTables("test");
```
5. Synchronize data.
a. Set the data synchronization mode and block status.
b. Constructs an **AbsPredicates** object to specify remote devices within the network to be synchronized.
c. Call the **Sync()** method to synchronize data.
The sample code is as follows:
```
SyncOption option;
option.mode = PUSH;
option.isBlock = true;
AbsRdbPredicates predicate("test");
predicate.InAllDevices();
store->Sync(option, predicate, [] (const SyncResult& result) {
for (const auto& [device, status] : result) {
LogI("device=%s status=%d", device.c_str(), status);
}
});
```
6. Subscribe to distributed data.
a. Override the **OnChange()** function.
b. Define the distributed data subscription type.
c. Call APIs to subscribe to or unsubscribe from distributed data.
The sample code is as follows:
```
class MyObserver : public RdbStoreObserver {
public:
void OnChange(const std::vector<std::string>& devices) override {
for (const auto& device : devices) {
LOGI("device=%s data change", device.c_str());
}
}
};
SubscribeOption option;
option.mode = SubscribeMode::REMOTE;
MyObserver observer;
store->Subscribe(option, &observer); // Subscribe to distributed data.
store->UnSubscribe(option, &observer); // Unsubscribe from distributed data.
```
7. Query data across devices.
a. Obtain the distributed table name for a remote device based on the local table name.
b. Run SQL statements to query data in the RDB store of the remote device.
The sample code is as follows:
```
std::string tableName = store->ObtainDistributedTableName("123456789abcd", "test");
auto resultSet = store->QuerySql("SELECT * from ?;", tableName);
```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册