#鸿蒙学习大百科#如何删除键值型数据库中某个key的值?

如何删除键值型数据库中某个key的值?

HarmonyOS
2024-10-23 11:23:54
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
花鸟吹雪
try {
  kvStore.put("name", "李四", (err) => {
    if (err !== undefined) {
      console.error(`Failed to put data. Code:${err.code},message:${err.message}`);
      return;
    }
    console.info('Succeeded in putting data.');
    kvStore = kvStore as distributedKVStore.SingleKVStore;
    kvStore.delete("name", (err) => {
      if (err !== undefined) {
        console.error(`Failed to delete data. Code:${err.code},message:${err.message}`);
        return;
      }
      console.info('Succeeded in deleting data.');
    });
  });
} catch (e) {
  let error = e as BusinessError;
  console.error(`An unexpected error occurred. Code:${error.code},message:${error.message}`);
}
分享
微博
QQ
微信
回复
2024-10-23 17:28:01
相关问题