Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a80a0e4c
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
You need to sign in or sign up before continuing.
提交
a80a0e4c
编写于
6月 13, 2022
作者:
S
songruirui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改
Signed-off-by:
N
songruirui
<
songruirui1@huawei.com
>
上级
44970dcb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
140 deletion
+55
-140
zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md
...nce/apis/js-apis-application-DataShareExtensionAbility.md
+31
-53
zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md
.../application-dev/reference/apis/js-apis-data-dataShare.md
+24
-87
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-application-DataShareExtensionAbility.md
浏览文件 @
a80a0e4c
...
...
@@ -40,21 +40,19 @@ let TBL_NAME = "TBL00";
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
let
rdbStore
;
onCreate
(
want
,
callback
)
{
console
.
log
(
'
DataShareExtAbility onCreate, want:
'
+
want
.
abilityName
);
console
.
log
(
'
DataShareExtAbility onCreate, this.context:
'
+
this
.
context
);
onCreate
(
want
:
Want
,
callback
:
AsyncCallback
&
lt
;
void
&
gt
;)
{
rdb
.
getRdbStore
(
this
.
context
,
{
name
:
DB_NAME
},
1
,
function
(
err
,
data
)
{
console
.
log
(
'
getRdbStore fail, error message :
'
+
err
);
console
.
log
(
'
getRdbStore done, data :
'
+
data
);
let
rdbStore
=
data
;
rdbStore
=
data
;
rdbStore
.
executeSql
(
DDL_TBL_CREATE
,
[],
function
(
err
)
{
console
.
log
(
'
executeSql
fail
, error message :
'
+
err
);
console
.
log
(
'
executeSql
done
, error message :
'
+
err
);
});
callback
();
});
callback
();
}
```
...
...
@@ -64,7 +62,7 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe
在数据库插入时回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -77,11 +75,7 @@ insert?(uri: string, valueBucket: ValuesBucket, callback: AsyncCallback<numbe
**示例:**
```
ts
import
rdb
from
'
@ohos.data.rdb
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
rdbStore
;
insert
(
uri
,
value
,
callback
)
{
insert
(
uri
:
string
,
valueBucket
:
ValuesBucket
,
callback
:
AsyncCallback
&
lt
;
number
&
gt
;)
{
if
(
value
==
null
)
{
console
.
info
(
'
invalid valueBuckets
'
);
return
;
...
...
@@ -101,7 +95,7 @@ update?(uri: string, predicates: DataSharePredicates, valueBucket: ValuesBucket,
在数据库更新时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -115,11 +109,7 @@ update?(uri: string, predicates: DataSharePredicates, valueBucket: ValuesBucket,
**示例:**
```
ts
import
rdb
from
'
@ohos.data.rdb
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
rdbStore
;
update
(
uri
,
predicates
,
value
,
callback
)
{
update
(
uri
:
string
,
predicates
:
DataSharePredicates
,
valueBucket
:
ValuesBucket
,
callback
:
AsyncCallback
&
lt
;
number
&
gt
;)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
return
;
}
...
...
@@ -137,7 +127,7 @@ query?(uri: string, predicates: DataSharePredicates, columns: Array<string>
在查询数据库时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -151,11 +141,7 @@ query?(uri: string, predicates: DataSharePredicates, columns: Array<string>
**示例:**
```
ts
import
rdb
from
'
@ohos.data.rdb
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
rdbStore
;
query
(
uri
,
predicates
,
columns
,
callback
)
{
query
(
uri
:
string
,
predicates
:
DataSharePredicates
,
columns
:
Array
&
lt
;
string
&
gt
;,
callback
:
AsyncCallback
&
lt
;
Object
&
gt
;)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
return
;
}
...
...
@@ -176,7 +162,7 @@ delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<
在删除数据库记录时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -189,11 +175,7 @@ delete?(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<
**示例:**
```
ts
import
rdb
from
'
@ohos.data.rdb
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
rdbStore
;
delete
(
uri
,
predicates
,
callback
)
{
delete
(
uri
:
string
,
predicates
:
DataSharePredicates
,
callback
:
AsyncCallback
&
lt
;
number
&
gt
;)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
return
;
}
...
...
@@ -211,7 +193,7 @@ BatchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy
在数据库批量插入时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -224,11 +206,7 @@ BatchInsert?(uri: string, valueBuckets: Array<ValuesBucket>, callback: Asy
**示例:**
```
ts
import
rdb
from
'
@ohos.data.rdb
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
rdbStore
;
batchInsert
(
uri
:
string
,
valueBuckets
,
callback
)
{
batchInsert
(
uri
:
string
,
valueBuckets
:
Array
&
lt
;
ValuesBucket
&
gt
;,
callback
:
AsyncCallback
&
lt
;
number
&
gt
;)
{
if
(
valueBuckets
==
null
||
valueBuckets
.
length
==
undefined
)
{
console
.
info
(
'
invalid valueBuckets
'
);
return
;
...
...
@@ -250,7 +228,7 @@ getType?(uri: string, callback: AsyncCallback<string>): void
获取给定URI对应的MIME类型时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -262,8 +240,8 @@ getType?(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
getType
(
uri
:
string
,
callback
)
{
let
err
;
getType
(
uri
:
string
,
callback
:
AsyncCallback
&
lt
;
string
&
gt
;
)
{
let
err
=
{
"
code
"
:
0
}
;
let
ret
=
"
image
"
;
callback
(
err
,
ret
);
}
...
...
@@ -275,7 +253,7 @@ getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Ar
获取支持文件的MIME类型时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -288,8 +266,8 @@ getFileTypes?(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Ar
**示例:**
```
ts
getFileTypes
(
uri
:
string
,
mimeTypeFilter
:
string
,
callback
)
{
let
err
;
getFileTypes
(
uri
:
string
,
mimeTypeFilter
:
string
,
callback
:
AsyncCallback
&
lt
;
Array
&
lt
;
string
&
gt
;
&
gt
;
)
{
let
err
=
{
"
code
"
:
0
}
;
let
ret
=
new
Array
(
"
type01
"
,
"
type02
"
,
"
type03
"
);
callback
(
err
,
ret
);
}
...
...
@@ -301,7 +279,7 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void
用户给定的URI转换为服务端使用的URI时回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -313,8 +291,8 @@ normalizeUri?(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
normalizeUri
(
uri
:
string
,
callback
)
{
let
err
;
normalizeUri
(
uri
:
string
,
callback
:
AsyncCallback
&
lt
;
string
&
gt
;
)
{
let
err
=
{
"
code
"
:
0
}
;
let
ret
=
"
normalize+
"
+
uri
;
callback
(
err
,
ret
);
}
...
...
@@ -326,7 +304,7 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void
服务端使用的URI转换为用户传入的初始URI时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -338,8 +316,8 @@ denormalizeUri?(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
denormalizeUri
(
uri
:
string
,
callback
)
{
let
err
;
denormalizeUri
(
uri
:
string
,
callback
:
AsyncCallback
&
lt
;
string
&
gt
;
)
{
let
err
=
{
"
code
"
:
0
}
;
let
ret
=
"
denormalize+
"
+
uri
;
callback
(
err
,
ret
);
}
...
...
@@ -351,7 +329,7 @@ openFile?(uri: string, mode: string, callback: AsyncCallback<number>): voi
在打开文件时服务端回调此接口,该方法可以选择性重写。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
。
**系统能力:**
SystemCapability.DistributedDataManager.DataShare.Provider
**参数:**
...
...
@@ -364,9 +342,9 @@ openFile?(uri: string, mode: string, callback: AsyncCallback<number>): voi
**示例:**
```
ts
openFile
(
uri
:
string
,
mode
,
callback
)
{
let
err
;
openFile
(
uri
:
string
,
mode
:
string
,
callback
:
AsyncCallback
&
lt
;
number
&
gt
;
)
{
let
err
=
{
"
code
"
:
0
}
;
let
fd
=
0
;
callback
(
err
,
fd
);
}
```
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-data-dataShare.md
浏览文件 @
a80a0e4c
...
...
@@ -36,13 +36,14 @@ createDataShareHelper(context: Context, uri: string, callback: AsyncCallback<
```
ts
import
dataShare
from
'
@ohos.data.dataShare
'
let
dseUri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShare
.
createDataShareHelper
(
this
.
context
,
dseUri
,
(
err
,
data
)
=>
{
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
dataShareHelper
;
dataShare
.
createDataShareHelper
(
this
.
context
,
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
info
(
"
createDataShareHelper failed, error message :
"
+
err
);
}
else
{
console
.
info
(
"
createDataShareHelper succeed, data :
"
+
data
);
let
dataShareHelper
=
data
;
dataShareHelper
=
data
;
}
});
```
...
...
@@ -73,10 +74,11 @@ createDataShareHelper(context: Context, uri: string): Promise<DataShareHelper
```
ts
import
dataShare
from
'
@ohos.data.dataShare
'
let
dseUri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShare
.
createDataShareHelper
(
this
.
context
,
dseUri
).
then
((
data
)
=>
{
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
dataShareHelper
;
dataShare
.
createDataShareHelper
(
this
.
context
,
uri
).
then
((
data
)
=>
{
console
.
info
(
"
createDataShareHelper succeed, data :
"
+
data
);
let
dataShareHelper
=
data
;
dataShareHelper
=
data
;
}).
catch
((
err
)
=>
{
console
.
info
(
"
createDataShareHelper failed, error message :
"
+
err
);
})
...
...
@@ -84,7 +86,7 @@ dataShare.createDataShareHelper(this.context, dseUri).then((data) => {
## DataShareHelper
DataShare管理工具实例,可使用此实例访问或管理服务端的数据。在调用DataShareHelper提供的方法前,需要先通过
[
createDataShareHelper
](
#datashare
.
createdatasharehelper
)
构建一个实例。
DataShare管理工具实例,可使用此实例访问或管理服务端的数据。在调用DataShareHelper提供的方法前,需要先通过
[
createDataShareHelper
](
#datasharecreatedatasharehelper
)
构建一个实例。
### openFile
...
...
@@ -105,8 +107,6 @@ openFile(uri: string, mode: string, callback: AsyncCallback<number>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
openFile
(
uri
,
"
rwt
"
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
info
(
"
openFile failed, error message :
"
+
err
);
...
...
@@ -141,8 +141,6 @@ openFile(uri: string, mode: string): Promise<number>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
openFile
(
uri
,
"
rwt
"
).
then
((
data
)
=>
{
console
.
info
(
"
openFile succeed, data :
"
+
data
);
let
fd
=
data
;
...
...
@@ -170,13 +168,10 @@ on(type: 'dataChange', uri: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
on
(
"
dataChange
"
,
uri
,
onCallback
);
export
function
onCallback
()
{
function
onCallback
()
{
console
.
info
(
"
**** Observer on callback ****
"
);
}
dataShareHelper
.
on
(
"
dataChange
"
,
uri
,
onCallback
);
```
### off('dataChange')
...
...
@@ -198,13 +193,10 @@ off(type: 'dataChange', uri: string, callback?: AsyncCallback<void>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
off
(
"
dataChange
"
,
uri
,
offCallback
);
export
function
offCallback
()
{
function
offCallback
()
{
console
.
info
(
"
**** Observer off callback ****
"
);
}
dataShareHelper
.
off
(
"
dataChange
"
,
uri
,
offCallback
);
```
### notifyChange
...
...
@@ -225,8 +217,6 @@ notifyChange(uri: string, callback: AsyncCallback<void>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
notifyChange
(
uri
,
()
=>
{
console
.
log
(
"
***** notifyChange *****
"
);
});
...
...
@@ -255,17 +245,6 @@ notifyChange(uri: string): Promise<void>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShare
.
createDataShareHelper
(
this
.
context
,
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
info
(
"
createDataShareHelper failed, error message :
"
+
err
);
}
else
{
console
.
info
(
"
createDataShareHelper succeed, data :
"
+
data
);
dataShareHelper
=
data
;
}
});
dataShareHelper
.
notifyChange
(
uri
);
```
...
...
@@ -287,15 +266,13 @@ getType(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
getType
(
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
log
(
"
getType failed, error message :
"
+
err
);
}
else
{
console
.
log
(
"
getType succeed, data :
"
+
data
);
let
result
=
data
;
}
}
});
```
...
...
@@ -322,8 +299,6 @@ getType(uri: string): Promise<string>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
getType
(
uri
).
then
((
data
)
=>
{
console
.
log
(
"
getType succeed, data :
"
+
data
);
}).
catch
((
err
)
=>
{
...
...
@@ -350,8 +325,6 @@ getFileTypes(uri: string, mimeTypeFilter: string, callback: AsyncCallback<Arr
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
mimeTypeFilter
=
"
image/*
"
;
dataShareHelper
.
getFileTypes
(
uri
,
mimeTypeFilter
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -362,8 +335,6 @@ dataShareHelper.getFileTypes(uri, mimeTypeFilter, (err,data) => {
});
```
### getFileTypes
getFileTypes(uri: string, mimeTypeFilter: string): Promise
<
Array
<
string
>>
...
...
@@ -388,8 +359,6 @@ getFileTypes(uri: string, mimeTypeFilter: string): Promise<Array<string>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
mimeTypeFilter
=
"
image/*
"
;
dataShareHelper
.
getFileTypes
(
uri
,
mimeTypeFilter
).
then
((
data
)
=>
{
console
.
log
(
"
getFileTypes succeed, data :
"
+
data
);
...
...
@@ -416,8 +385,6 @@ normalizeUri(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
normalizeUri
(
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
log
(
"
normalizeUri failed, error message :
"
+
err
);
...
...
@@ -450,8 +417,6 @@ normalizeUri(uri: string): Promise<string>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
normalizeUri
(
uri
).
then
((
data
)
=>
{
console
.
log
(
"
normalizeUri =
"
+
data
);
}).
catch
((
err
)
=>
{
...
...
@@ -477,8 +442,6 @@ denormalizeUri(uri: string, callback: AsyncCallback<string>): void
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
denormalizeUri
(
uri
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
log
(
"
denormalizeUri failed, error message :
"
+
err
);
...
...
@@ -511,8 +474,6 @@ denormalizeUri(uri: string): Promise<string>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
dataShareHelper
.
denormalizeUri
(
uri
).
then
((
data
)
=>
{
console
.
log
(
"
denormalizeUri =
"
+
data
);
}).
catch
((
err
)
=>
{
...
...
@@ -539,13 +500,10 @@ insert(uri: string, value: ValuesBucket, callback: AsyncCallback<number>):
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
const
valueBucket
=
{
"
name
"
:
"
rose
"
,
"
age
"
:
22
,
"
salary
"
:
200.5
,
"
blobType
"
:
u8
,
}
dataShareHelper
.
insert
(
uri
,
valueBucket
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -580,13 +538,10 @@ insert(uri: string, value: ValuesBucket): Promise<number>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
const
valueBucket
=
{
"
name
"
:
"
rose1
"
,
"
age
"
:
221
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,
}
dataShareHelper
.
insert
(
uri
,
valueBucket
).
then
((
data
)
=>
{
console
.
log
(
"
insert succeed, data :
"
+
data
);
...
...
@@ -614,11 +569,9 @@ batchInsert(uri: string, values: Array<ValuesBucket>, callback: AsyncCallb
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
vbs
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,},
{
"
name
"
:
"
roe13
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,})
let
vbs
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
{
"
name
"
:
"
roe13
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,})
dataShareHelper
.
batchInsert
(
uri
,
vbs
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
console
.
log
(
"
batchInsert failed, error message :
"
+
err
);
...
...
@@ -652,11 +605,9 @@ batchInsert(uri: string, values: Array<ValuesBucket>): Promise<number&g
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
vbs
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,},
{
"
name
"
:
"
roe13
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,})
let
vbs
=
new
Array
({
"
name
"
:
"
roe11
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
{
"
name
"
:
"
roe12
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,},
{
"
name
"
:
"
roe13
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,})
dataShareHelper
.
batchInsert
(
uri
,
vbs
).
then
((
data
)
=>
{
console
.
log
(
"
batchInsert succeed, data :
"
+
data
);
}).
catch
((
err
)
=>
{
...
...
@@ -683,8 +634,6 @@ delete(uri: string, predicates: DataSharePredicates, callback: AsyncCallback<
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
da
=
new
dataShare
.
DataSharePredicates
();
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
dataShareHelper
.
delete
(
uri
,
da
,
(
err
,
data
)
=>
{
...
...
@@ -720,8 +669,6 @@ delete(uri: string, predicates: DataSharePredicates): Promise<number>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
da
=
new
dataShare
.
DataSharePredicates
();
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
dataShareHelper
.
delete
(
uri
,
da
).
then
((
data
)
=>
{
...
...
@@ -751,15 +698,13 @@ update(uri: string, predicates: DataSharePredicates, value: ValuesBucket, callba
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
da
=
new
dataShare
.
DataSharePredicates
();
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
const
va
=
{
"
name
"
:
"
roe1
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,
}
dataShareHelper
.
update
(
uri
,
da
,
va
,
(
err
,
data
)
=>
{
if
(
err
!=
undefined
)
{
...
...
@@ -795,15 +740,13 @@ update(uri: string, predicates: DataSharePredicates, value: ValuesBucket): Promi
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
da
=
new
dataShare
.
DataSharePredicates
();
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
const
va
=
{
"
name
"
:
"
roe1
"
,
"
age
"
:
21
,
"
salary
"
:
20.5
,
"
blobType
"
:
u8
,
}
dataShareHelper
.
update
(
uri
,
da
,
va
).
then
((
data
)
=>
{
console
.
log
(
"
update succeed, data :
"
+
data
);
...
...
@@ -832,8 +775,6 @@ query(uri: string, predicates: DataSharePredicates, columns: Array<string>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
columns
=
[
"
*
"
];
let
da
=
new
dataShare
.
DataSharePredicates
();
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
...
...
@@ -841,13 +782,11 @@ dataShareHelper.query(uri, da, columns, (err, data) => {
if
(
err
!=
undefined
)
{
console
.
log
(
"
query failed, error message :
"
+
err
);
}
else
{
console
.
log
(
"
query succeed,
data :
"
+
data
);
console
.
log
(
"
query succeed,
ret :
"
+
data
.
rowCount
);
}
});
```
### query
query(uri: string, predicates: DataSharePredicates, columns: Array
<
string
>
): Promise
<
DataShareResultSet
>
...
...
@@ -873,13 +812,11 @@ query(uri: string, predicates: DataSharePredicates, columns: Array<string>
**示例:**
```
ts
let
dataShareHelper
;
let
uri
=
(
"
datashare:///com.samples.datasharetest.DataShare
"
);
let
columns
=
[
"
*
"
];
let
da
=
new
dataShare
.
DataSharePredicates
();
da
.
equalTo
(
"
name
"
,
"
ZhangSan
"
);
dataShareHelper
.
query
(
uri
,
da
,
columns
).
then
((
data
)
=>
{
console
.
log
(
"
query succeed,
data :
"
+
data
);
console
.
log
(
"
query succeed,
ret :
"
+
data
.
rowCount
);
}).
catch
((
err
)
=>
{
console
.
log
(
"
query failed, error message :
"
+
err
);
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录