Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
b63fa7c4
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,发现更多精彩内容 >>
未验证
提交
b63fa7c4
编写于
3月 01, 2023
作者:
O
openharmony_ci
提交者:
Gitee
3月 01, 2023
浏览文件
操作
浏览文件
下载
差异文件
!15295 [翻译完成】#I6DDB5 (仅涉及代码修改)
Merge pull request !15295 from Annie_wang/PR14276
上级
614d0d0c
dcffcc13
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
45 addition
and
45 deletion
+45
-45
en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
...nce/apis/js-apis-application-dataShareExtensionAbility.md
+45
-45
未找到文件。
en/application-dev/reference/apis/js-apis-application-dataShareExtensionAbility.md
浏览文件 @
b63fa7c4
...
@@ -14,7 +14,7 @@ The **DataShareExtensionAbility** module provides data share services based on t
...
@@ -14,7 +14,7 @@ The **DataShareExtensionAbility** module provides data share services based on t
## Modules to Import
## Modules to Import
```
ts
```
ts
import
DataShareExtensionAbility
from
'
@ohos.application.DataShareExtensionAbility
'
import
DataShareExtensionAbility
from
'
@ohos.application.DataShareExtensionAbility
'
;
```
```
## URI Naming Rule
## URI Naming Rule
...
@@ -65,11 +65,11 @@ Called by the server to initialize service logic when the DataShare client conne
...
@@ -65,11 +65,11 @@ Called by the server to initialize service logic when the DataShare client conne
```
ts
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
...
@@ -78,10 +78,10 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
...
@@ -78,10 +78,10 @@ export default class DataShareExtAbility extends DataShareExtensionAbility {
name
:
DB_NAME
,
name
:
DB_NAME
,
securityLevel
:
rdb
.
SecurityLevel
.
S1
securityLevel
:
rdb
.
SecurityLevel
.
S1
},
function
(
err
,
data
)
{
},
function
(
err
,
data
)
{
console
.
log
(
'
getRdbStore done, data :
'
+
data
);
console
.
log
(
'
getRdbStore done, data :
${data}
'
);
rdbStore
=
data
;
rdbStore
=
data
;
rdbStore
.
executeSql
(
DDL_TBL_CREATE
,
[],
function
(
err
)
{
rdbStore
.
executeSql
(
DDL_TBL_CREATE
,
[],
function
(
err
)
{
console
.
log
(
'
executeSql done, error message :
'
+
err
);
console
.
log
(
'
executeSql done, error message :
${err}
'
);
});
});
if
(
callback
)
{
if
(
callback
)
{
callback
();
callback
();
...
@@ -112,22 +112,22 @@ Inserts data into the database. This API can be overridden as required.
...
@@ -112,22 +112,22 @@ Inserts data into the database. This API can be overridden as required.
```
ts
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
insert
(
uri
,
valueBucket
,
callback
)
{
insert
(
uri
,
valueBucket
,
callback
)
{
if
(
valueBucket
==
null
)
{
if
(
valueBucket
==
=
null
)
{
console
.
info
(
'
invalid valueBuckets
'
);
console
.
info
(
'
invalid valueBuckets
'
);
return
;
return
;
}
}
rdbStore
.
insert
(
TBL_NAME
,
valueBucket
,
function
(
err
,
ret
)
{
rdbStore
.
insert
(
TBL_NAME
,
valueBucket
,
function
(
err
,
ret
)
{
console
.
info
(
'
callback ret:
'
+
ret
);
console
.
info
(
'
callback ret:
${ret}
'
);
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
ret
);
callback
(
err
,
ret
);
}
}
});
});
...
@@ -157,20 +157,20 @@ Updates data in the database. This API can be overridden as required.
...
@@ -157,20 +157,20 @@ Updates data in the database. This API can be overridden as required.
```
ts
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
update
(
uri
,
predicates
,
valueBucket
,
callback
)
{
update
(
uri
,
predicates
,
valueBucket
,
callback
)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
if
(
predicates
==
=
null
||
predicates
=
==
undefined
)
{
return
;
return
;
}
}
rdbStore
.
update
(
TBL_NAME
,
valueBucket
,
predicates
,
function
(
err
,
ret
)
{
rdbStore
.
update
(
TBL_NAME
,
valueBucket
,
predicates
,
function
(
err
,
ret
)
{
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
ret
);
callback
(
err
,
ret
);
}
}
});
});
...
@@ -199,20 +199,20 @@ Deletes data from the database. This API can be overridden as required.
...
@@ -199,20 +199,20 @@ Deletes data from the database. This API can be overridden as required.
```
ts
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
delete
(
uri
,
predicates
,
callback
)
{
delete
(
uri
,
predicates
,
callback
)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
if
(
predicates
==
=
null
||
predicates
=
==
undefined
)
{
return
;
return
;
}
}
rdbStore
.
delete
(
TBL_NAME
,
predicates
,
function
(
err
,
ret
)
{
rdbStore
.
delete
(
TBL_NAME
,
predicates
,
function
(
err
,
ret
)
{
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
ret
);
callback
(
err
,
ret
);
}
}
});
});
...
@@ -242,23 +242,23 @@ Queries data from the database. This API can be overridden as required.
...
@@ -242,23 +242,23 @@ Queries data from the database. This API can be overridden as required.
```
ts
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
query
(
uri
,
predicates
,
columns
,
callback
)
{
query
(
uri
,
predicates
,
columns
,
callback
)
{
if
(
predicates
==
null
||
predicates
==
undefined
)
{
if
(
predicates
==
=
null
||
predicates
=
==
undefined
)
{
return
;
return
;
}
}
rdbStore
.
query
(
TBL_NAME
,
predicates
,
columns
,
function
(
err
,
resultSet
)
{
rdbStore
.
query
(
TBL_NAME
,
predicates
,
columns
,
function
(
err
,
resultSet
)
{
if
(
resultSet
!=
undefined
)
{
if
(
resultSet
!=
=
undefined
)
{
console
.
info
(
'
resultSet.rowCount:
'
+
resultSet
.
rowCount
);
console
.
info
(
'
resultSet.rowCount:
${resultSet.rowCount}
'
);
}
}
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
resultSet
);
callback
(
err
,
resultSet
);
}
}
});
});
...
@@ -287,23 +287,23 @@ Batch inserts data into the database. This API is called by the server and can b
...
@@ -287,23 +287,23 @@ Batch inserts data into the database. This API is called by the server and can b
```
ts
```
ts
import
rdb
from
'
@ohos.data.relationalStore
'
;
import
rdb
from
'
@ohos.data.relationalStore
'
;
let
DB_NAME
=
"
DB00.db
"
;
let
DB_NAME
=
'
DB00.db
'
;
let
TBL_NAME
=
"
TBL00
"
;
let
TBL_NAME
=
'
TBL00
'
;
let
DDL_TBL_CREATE
=
"
CREATE TABLE IF NOT EXISTS
"
let
DDL_TBL_CREATE
=
'
CREATE TABLE IF NOT EXISTS
'
+
TBL_NAME
+
TBL_NAME
+
"
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
"
;
+
'
(id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER, phoneNumber DOUBLE, isStudent BOOLEAN, Binary BINARY)
'
;
let
rdbStore
;
let
rdbStore
;
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
batchInsert
(
uri
,
valueBuckets
,
callback
)
{
batchInsert
(
uri
,
valueBuckets
,
callback
)
{
if
(
valueBuckets
==
null
||
valueBuckets
.
length
==
undefined
)
{
if
(
valueBuckets
==
=
null
||
valueBuckets
.
length
=
==
undefined
)
{
console
.
info
(
'
invalid valueBuckets
'
);
console
.
info
(
'
invalid valueBuckets
'
);
return
;
return
;
}
}
let
resultNum
=
valueBuckets
.
length
let
resultNum
=
valueBuckets
.
length
;
valueBuckets
.
forEach
(
vb
=>
{
valueBuckets
.
forEach
(
vb
=>
{
rdbStore
.
insert
(
TBL_NAME
,
vb
,
function
(
err
,
ret
)
{
rdbStore
.
insert
(
TBL_NAME
,
vb
,
function
(
err
,
ret
)
{
if
(
callback
!=
undefined
)
{
if
(
callback
!=
=
undefined
)
{
callback
(
err
,
resultNum
);
callback
(
err
,
resultNum
);
}
}
});
});
...
@@ -332,8 +332,8 @@ Normalizes a URI. This API can be overridden as required.
...
@@ -332,8 +332,8 @@ Normalizes a URI. This API can be overridden as required.
```
ts
```
ts
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
normalizeUri
(
uri
,
callback
)
{
normalizeUri
(
uri
,
callback
)
{
let
err
=
{
"
code
"
:
0
};
let
err
=
{
'
code
'
:
0
};
let
ret
=
"
normalize+
"
+
uri
;
let
ret
=
'
normalize+${uri}
'
;
callback
(
err
,
ret
);
callback
(
err
,
ret
);
}
}
};
};
...
@@ -359,8 +359,8 @@ Denormalizes a URI. This API can be overridden as required.
...
@@ -359,8 +359,8 @@ Denormalizes a URI. This API can be overridden as required.
```
ts
```
ts
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
export
default
class
DataShareExtAbility
extends
DataShareExtensionAbility
{
denormalizeUri
(
uri
,
callback
)
{
denormalizeUri
(
uri
,
callback
)
{
let
err
=
{
"
code
"
:
0
};
let
err
=
{
'
code
'
:
0
};
let
ret
=
"
denormalize+
"
+
uri
;
let
ret
=
'
denormalize+${uri}
'
;
callback
(
err
,
ret
);
callback
(
err
,
ret
);
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录