diff --git a/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md b/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md index a75c2439c731de08188ef246f58dbd0bf6a06629..b6fd283f8de612c1d550362446c873137b10eb36 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md +++ b/zh-cn/application-dev/reference/apis/js-apis-data-relationalStore.md @@ -64,7 +64,7 @@ const STORE_CONFIG = { relationalStore.getRdbStore(context, STORE_CONFIG, function (err, rdbStore) { store = rdbStore; if (err) { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Get RdbStore successfully.`); @@ -87,7 +87,7 @@ class EntryAbility extends UIAbility { relationalStore.getRdbStore(this.context, STORE_CONFIG, function (err, rdbStore) { store = rdbStore; if (err) { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Get RdbStore successfully.`); @@ -148,7 +148,7 @@ promise.then(async (rdbStore) => { store = rdbStore; console.info(`Get RdbStore successfully.`); }).catch((err) => { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -170,7 +170,7 @@ class EntryAbility extends UIAbility { store = rdbStore; console.info(`Get RdbStore successfully.`) }).catch((err) => { - console.error(`Get RdbStore failed, err: ${err}`); + console.error(`Get RdbStore failed, code is ${err.code},message is ${err.message}`); }) } } @@ -1304,7 +1304,7 @@ const valueBucket = { }; store.insert("EMPLOYEE", valueBucket, function (err, rowId) { if (err) { - console.error(`Insert is failed, err: ${err}`); + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Insert is successful, rowId = ${rowId}`); @@ -1347,7 +1347,7 @@ const valueBucket = { }; store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rowId) { if (err) { - console.error(`Insert is failed, err: ${err}`); + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Insert is successful, rowId = ${rowId}`); @@ -1396,7 +1396,7 @@ let promise = store.insert("EMPLOYEE", valueBucket); promise.then((rowId) => { console.info(`Insert is successful, rowId = ${rowId}`); }).catch((err) => { - console.error(`Insert is failed, err: ${err}`); + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1443,7 +1443,7 @@ let promise = store.insert("EMPLOYEE", valueBucket, relationalStore.ConflictReso promise.then((rowId) => { console.info(`Insert is successful, rowId = ${rowId}`); }).catch((err) => { - console.error(`Insert is failed, err: ${err}`); + console.error(`Insert is failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1496,7 +1496,7 @@ const valueBucket3 = { let valueBuckets = new Array(valueBucket1, valueBucket2, valueBucket3); store.batchInsert("EMPLOYEE", valueBuckets, function(err, insertNum) { if (err) { - console.error(`batchInsert is failed, err: ${err}`); + console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`); return; } console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`); @@ -1559,7 +1559,7 @@ let promise = store.batchInsert("EMPLOYEE", valueBuckets); promise.then((insertNum) => { console.info(`batchInsert is successful, the number of values that were inserted = ${insertNum}`); }).catch((err) => { - console.error(`batchInsert is failed, err: ${err}`); + console.error(`batchInsert is failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1600,7 +1600,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Lisa"); store.update(valueBucket, predicates, function (err, rows) { if (err) { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Updated row count: ${rows}`); @@ -1645,7 +1645,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Lisa"); store.update(valueBucket, predicates, relationalStore.ConflictResolution.ON_CONFLICT_REPLACE, function (err, rows) { if (err) { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Updated row count: ${rows}`); @@ -1696,7 +1696,7 @@ let promise = store.update(valueBucket, predicates); promise.then(async (rows) => { console.info(`Updated row count: ${rows}`); }).catch((err) => { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1745,7 +1745,7 @@ let promise = store.update(valueBucket, predicates, relationalStore.ConflictReso promise.then(async (rows) => { console.info(`Updated row count: ${rows}`); }).catch((err) => { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1757,6 +1757,8 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core +**模型约束:** 此接口仅可在Stage模型下可用。 + **系统接口:** 此接口为系统接口。 **参数:** @@ -1790,7 +1792,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Lisa"); store.update("EMPLOYEE", valueBucket, predicates, function (err, rows) { if (err) { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Updated row count: ${rows}`); @@ -1805,6 +1807,8 @@ update(table: string, values: ValuesBucket, predicates: dataSharePredicates.Data **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core +**模型约束:** 此接口仅可在Stage模型下可用。 + **系统接口:** 此接口为系统接口。 **参数:** @@ -1845,7 +1849,7 @@ let promise = store.update("EMPLOYEE", valueBucket, predicates); promise.then(async (rows) => { console.info(`Updated row count: ${rows}`); }).catch((err) => { - console.error(`Updated failed, err: ${err}`); + console.error(`Updated failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1879,7 +1883,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Lisa"); store.delete(predicates, function (err, rows) { if (err) { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete rows: ${rows}`); @@ -1923,7 +1927,7 @@ let promise = store.delete(predicates); promise.then((rows) => { console.info(`Delete rows: ${rows}`); }).catch((err) => { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -1935,6 +1939,8 @@ delete(table: string, predicates: dataSharePredicates.DataSharePredicates, callb **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core +**模型约束:** 此接口仅可在Stage模型下可用。 + **系统接口:** 此接口为系统接口。 **参数:** @@ -1961,7 +1967,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Lisa"); store.delete("EMPLOYEE", predicates, function (err, rows) { if (err) { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete rows: ${rows}`); @@ -1976,6 +1982,8 @@ delete(table: string, predicates: dataSharePredicates.DataSharePredicates):Promi **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core +**模型约束:** 此接口仅可在Stage模型下可用。 + **系统接口:** 此接口为系统接口。 **参数:** @@ -2009,7 +2017,7 @@ let promise = store.delete("EMPLOYEE", predicates); promise.then((rows) => { console.info(`Delete rows: ${rows}`); }).catch((err) => { - console.error(`Delete failed, err: ${err}`); + console.error(`Delete failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2036,7 +2044,7 @@ let predicates = new relationalStore.RdbPredicates("EMPLOYEE"); predicates.equalTo("NAME", "Rose"); store.query(predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { if (err) { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); return; } console.info(`ResultSet column names: ${resultSet.columnNames}`); @@ -2075,7 +2083,7 @@ promise.then((resultSet) => { console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column count: ${resultSet.columnCount}`); }).catch((err) => { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2087,6 +2095,8 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core +**模型约束:** 此接口仅可在Stage模型下可用。 + **系统接口:** 此接口为系统接口。 **参数:** @@ -2106,7 +2116,7 @@ let predicates = new dataSharePredicates.DataSharePredicates(); predicates.equalTo("NAME", "Rose"); store.query("EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function (err, resultSet) { if (err) { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); return; } console.info(`ResultSet column names: ${resultSet.columnNames}`); @@ -2122,6 +2132,8 @@ query(table: string, predicates: dataSharePredicates.DataSharePredicates, column **系统能力:** SystemCapability.DistributedDataManager.RelationalStore.Core +**模型约束:** 此接口仅可在Stage模型下可用。 + **系统接口:** 此接口为系统接口。 **参数:** @@ -2149,7 +2161,7 @@ promise.then((resultSet) => { console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column count: ${resultSet.columnCount}`); }).catch((err) => { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2197,7 +2209,7 @@ predicates.greaterThan("id", 0); store.remoteQuery(deviceId, "EMPLOYEE", predicates, ["ID", "NAME", "AGE", "SALARY", "CODES"], function(err, resultSet) { if (err) { - console.error(`Failed to remoteQuery, err: ${err}`); + console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`); return; } console.info(`ResultSet column names: ${resultSet.columnNames}`); @@ -2257,7 +2269,7 @@ promise.then((resultSet) => { console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column count: ${resultSet.columnCount}`); }).catch((err) => { - console.error(`Failed to remoteQuery, err: ${err}`); + console.error(`Failed to remoteQuery, code is ${err.code},message is ${err.message}`); }) ``` @@ -2282,7 +2294,7 @@ querySql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallback& ```js store.querySql("SELECT * FROM EMPLOYEE CROSS JOIN BOOK WHERE BOOK.NAME = ?", ['sanguo'], function (err, resultSet) { if (err) { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); return; } console.info(`ResultSet column names: ${resultSet.columnNames}`); @@ -2319,7 +2331,7 @@ promise.then((resultSet) => { console.info(`ResultSet column names: ${resultSet.columnNames}`); console.info(`ResultSet column count: ${resultSet.columnCount}`); }).catch((err) => { - console.error(`Query failed, err: ${err}`); + console.error(`Query failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2353,7 +2365,7 @@ executeSql(sql: string, bindArgs: Array<ValueType>, callback: AsyncCallbac const SQL_DELETE_TABLE = "DELETE FROM test WHERE name = ?" store.executeSql(SQL_DELETE_TABLE, ['zhangsan'], function(err) { if (err) { - console.error(`ExecuteSql failed, err: ${err}`); + console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Delete table done.`); @@ -2397,7 +2409,7 @@ let promise = store.executeSql(SQL_DELETE_TABLE); promise.then(() => { console.info(`Delete table done.`); }).catch((err) => { - console.error(`ExecuteSql failed, err: ${err}`); + console.error(`ExecuteSql failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2428,7 +2440,7 @@ const STORE_CONFIG = { }; relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { if (err) { - console.error(`GetRdbStore failed, err: ${err}`); + console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`); return; } store.beginTransaction(); @@ -2462,7 +2474,7 @@ const STORE_CONFIG = { }; relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { if (err) { - console.error(`GetRdbStore failed, err: ${err}`); + console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`); return; } store.beginTransaction(); @@ -2496,7 +2508,7 @@ const STORE_CONFIG = { }; relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { if (err) { - console.error(`GetRdbStore failed, err: ${err}`); + console.error(`GetRdbStore failed, code is ${err.code},message is ${err.message}`); return; } try { @@ -2511,7 +2523,7 @@ relationalStore.getRdbStore(context, STORE_CONFIG, async function (err, store) { await store.insert("test", valueBucket); store.commit(); } catch (err) { - console.error(`Transaction failed, err: ${err}`); + console.error(`Transaction failed, code is ${err.code},message is ${err.message}`); store.rollBack(); } }) @@ -2537,7 +2549,7 @@ backup(destName:string, callback: AsyncCallback<void>):void ```js store.backup("dbBackup.db", function(err) { if (err) { - console.error(`Backup failed, err: ${err}`); + console.error(`Backup failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Backup success.`); @@ -2571,7 +2583,7 @@ let promiseBackup = store.backup("dbBackup.db"); promiseBackup.then(()=>{ console.info(`Backup success.`); }).catch((err)=>{ - console.error(`Backup failed, err: ${err}`); + console.error(`Backup failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2595,7 +2607,7 @@ restore(srcName:string, callback: AsyncCallback<void>):void ```js store.restore("dbBackup.db", function(err) { if (err) { - console.error(`Restore failed, err: ${err}`); + console.error(`Restore failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Restore success.`); @@ -2629,7 +2641,7 @@ let promiseRestore = store.restore("dbBackup.db"); promiseRestore.then(()=>{ console.info(`Restore success.`); }).catch((err)=>{ - console.error(`Restore failed, err: ${err}`); + console.error(`Restore failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2655,7 +2667,7 @@ setDistributedTables(tables: Array<string>, callback: AsyncCallback<voi ```js store.setDistributedTables(["EMPLOYEE"], function (err) { if (err) { - console.error(`SetDistributedTables failed, err: ${err}`); + console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`); return; } console.info(`SetDistributedTables successfully.`); @@ -2691,7 +2703,7 @@ let promise = store.setDistributedTables(["EMPLOYEE"]); promise.then(() => { console.info(`SetDistributedTables successfully.`); }).catch((err) => { - console.error(`SetDistributedTables failed, err: ${err}`); + console.error(`SetDistributedTables failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2736,7 +2748,7 @@ deviceManager.createDeviceManager("com.example.appdatamgrverify", (err, manager) store.obtainDistributedTableName(deviceId, "EMPLOYEE", function (err, tableName) { if (err) { - console.error(`ObtainDistributedTableName failed, err: ${err}`); + console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`); return; } console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); @@ -2791,7 +2803,7 @@ let promise = store.obtainDistributedTableName(deviceId, "EMPLOYEE"); promise.then((tableName) => { console.info(`ObtainDistributedTableName successfully, tableName= ${tableName}`); }).catch((err) => { - console.error(`ObtainDistributedTableName failed, err: ${err}`); + console.error(`ObtainDistributedTableName failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2836,7 +2848,7 @@ let predicates = new relationalStore.RdbPredicates('EMPLOYEE'); predicates.inDevices(deviceIds); store.sync(relationalStore.SyncMode.SYNC_MODE_PUSH, predicates, function (err, result) { if (err) { - console.error(`Sync failed, err: ${err}`); + console.error(`Sync failed, code is ${err.code},message is ${err.message}`); return; } console.info(`Sync done.`); @@ -2897,7 +2909,7 @@ promise.then((result) =>{ console.info(`device= ${result[i][0]}, status= ${result[i][1]}`); } }).catch((err) => { - console.error(`Sync failed, err: ${err}`); + console.error(`Sync failed, code is ${err.code},message is ${err.message}`); }) ``` @@ -2928,7 +2940,7 @@ function storeObserver(devices) { try { store.on('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); } catch (err) { - console.error(`Register observer failed, err: ${err}`); + console.error(`Register observer failed, code is ${err.code},message is ${err.message}`); } ``` @@ -2959,7 +2971,7 @@ function storeObserver(devices) { try { store.off('dataChange', relationalStore.SubscribeType.SUBSCRIBE_TYPE_REMOTE, storeObserver); } catch (err) { - console.error(`Unregister observer failed, err: ${err}`); + console.error(`Unregister observer failed, code is ${err.code},message is ${err.message}`); } ``` @@ -3110,7 +3122,7 @@ promise.then((resultSet) => { resultSet.goTo(1); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3151,7 +3163,7 @@ promise.then((resultSet) => { resultSet.goToRow(5); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3187,7 +3199,7 @@ promise.then((resultSet) => { resultSet.goToFirstRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3222,7 +3234,7 @@ promise.then((resultSet) => { resultSet.goToLastRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3257,7 +3269,7 @@ promise.then((resultSet) => { resultSet.goToNextRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3292,7 +3304,7 @@ promise.then((resultSet) => { resultSet.goToPreviousRow(); resultSet.close(); }).catch((err) => { - console.error(`query failed, err: ${err}`); + console.error(`query failed, code is ${err.code},message is ${err.message}`); }); ``` @@ -3450,7 +3462,7 @@ let promiseClose = store.query(predicatesClose, ["ID", "NAME", "AGE", "SALARY", promiseClose.then((resultSet) => { resultSet.close(); }).catch((err) => { - console.error(`resultset close failed, err: ${err}`); + console.error(`resultset close failed, code is ${err.code},message is ${err.message}`); }); ```