Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
unidocs-uni-app-x-zh
提交
75e4a65b
U
unidocs-uni-app-x-zh
项目概览
DCloud
/
unidocs-uni-app-x-zh
通知
144
Star
2
Fork
33
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
9
列表
看板
标记
里程碑
合并请求
11
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
unidocs-uni-app-x-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
9
Issue
9
列表
看板
标记
里程碑
合并请求
11
合并请求
11
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
75e4a65b
编写于
8月 05, 2024
作者:
G
git_robot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新 utsJson.json、utsApiJson.json、utsComJson.json、utsUnicloudApiJson.json
上级
263a0dfb
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
2 addition
and
2 deletion
+2
-2
docs/.vuepress/utils/utsApiJson.json
docs/.vuepress/utils/utsApiJson.json
+1
-1
docs/.vuepress/utils/utsUnicloudApiJson.json
docs/.vuepress/utils/utsUnicloudApiJson.json
+1
-1
未找到文件。
docs/.vuepress/utils/utsApiJson.json
浏览文件 @
75e4a65b
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
docs/.vuepress/utils/utsUnicloudApiJson.json
浏览文件 @
75e4a65b
{
"uniCloud_props"
:{
"name"
:
"# uniCloud"
,
"description"
:
""
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| config | **UniCloudInitOptions** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| provider | string | 是 | - | - | 服务商,目前支持 aliyun、tencent、alipay |
\n
@| spaceName | string | 否 | - | - | 服务空间名 |
\n
@| spaceId | string | 是 | - | - | 服务空间id |
\n
@| clientSecret | string | 否 | - | - | 阿里云clientSecret |
\n
@| endpoint | string | 否 | - | - | 阿里云endpoint |
\n
@| spaceAppId | string | 否 | - | - | 支付宝云spaceAppId |
\n
@| accessKey | string | 否 | - | - | 支付宝云accessKey |
\n
@| secretKey | string | 否 | - | - | 支付宝云secretKey |
\n
@| wsEndpoint | string | 否 | - | - | 支付宝云 WebSocket Endpoint |
\n
| mixinDatacom | any | 是 | - | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"callFunction"
:{
"name"
:
"## callFunction(options) @callfunction"
,
"description"
:
"请求云函数"
,
"compatibility"
:
"### callFunction
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | **UniCloudCallFunctionOptions** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| name | string ([string.CloudFunctionString](/uts/data-type.md#ide-string)) | 是 | - | - | 云函数名 |
\n
@| data | any | 否 | - | - | 云函数参数 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudCallFunctionResult
\\
<T>](#unicloudcallfunctionresult-values)> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| result | T | 是 | - | - | 云函数返回结果 |
\n
@| requestId | string | 否 | - | - | 云函数请求id |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudFunction.callFunction)"
},
"cloudFunction"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/cloud-function.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/cloud-function/cloud-function
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
callFunction
\"
>请求云函数</button>
\n
<button type=
\"
primary
\"
@click=
\"
callFunctionWithGeneric
\"
>请求云函数传入泛型</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '请求云函数',
\n
callFunctionResult: {},
\n
callFunctionError: {},
\n
genericDemoShowMessage: '',
\n
isUniTest: false
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
if (this.isUniTest) {
\n
uni.hideToast()
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async callFunctionWithGeneric() : Promise<void> {
\n
type EchoCfResult = {
\n
showMessage: string
\n
}
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction<EchoCfResult>({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
uni.hideLoading()
\n
this.genericDemoShowMessage = result.showMessage
\n
this.notify(result.showMessage, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async callFunction() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
this.callFunctionResult = result
\n
console.log(JSON.stringify(result))
\n
uni.hideLoading()
\n
this.notify(result['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"importObject"
:{
"name"
:
"## importObject(objectName, options?) @importobject"
,
"description"
:
"引用云对象"
,
"compatibility"
:
"### importObject
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| objectName | string ([string.CloudObjectString](/uts/data-type.md#ide-string)) | 是 | - | - | - |
\n
| options | **UniCloudImportObjectOptions** | 否 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| customUI | boolean
\\
| null | 否 | - | - | 是否移除自动展示的ui |
\n
@| loadingOptions | **UniCloudImportObjectLoadingOptions**
\\
| null | 否 | - | - | loading界面配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| title | string
\\
| null | 否 | - | - | 加载框标题 |
\n
@@| mask | boolean
\\
| null | 否 | - | - | 加载框是否显示mask |
\n
@| errorOptions | **UniCloudImportObjectErrorOptions**
\\
| null | 否 | - | - | 错误提示配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| type | string
\\
| null | 否 | - | - | 错误提示类型,可以是modal或者toast |
\n
@@| retry | boolean
\\
| null | 否 | - | - | 是否显示重试按钮 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudCloudObjectCaller](#unicloudcloudobjectcaller-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| _obj | [InternalUniCloudCloudObject](#internalunicloudcloudobject-values) | 是 | - | - | - |
\n
##### InternalUniCloudCloudObject 的方法 @internalunicloudcloudobject-values
\n\n
##### callMethod(methodName, args) @callmethod
\n\n
###### callMethod
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| methodName | string | 是 | - | - | - |
\n
| args | Array
\\
<any
\\
| null
\\
> | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<T> |
\n
\n\n
#### UniCloudCloudObjectCaller 的方法 @unicloudcloudobjectcaller-values
\n\n
#### _getArgs(args?) @_getargs
\n\n
##### _getArgs
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| args | Array
\\
<any
\\
| null
\\
> | 否 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Array
\\
<any
\\
| null
\\
> |
\n
\n
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudObject.importObject)"
},
"cloudObject"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/cloud-object.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/cloud-object/cloud-object
\n
>Template
\n
```vue
\n
<template>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
addTodo
\"
>添加Todo</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
addTodoWithGeneric
\"
>
\r\n
添加Todo传入泛型
\r\n
</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
randomFail
\"
>随机触发失败重试</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
fail
\"
>云对象失败调用</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
failWithNumberErrCode
\"
>
\r\n
云对象数字错误码
\r\n
</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
success
\"
>云对象成功调用</button>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n\r\n
<style></style>
\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: '请求云对象',
\r\n
todoTitle: '学习编程',
\r\n
todoContent: '熟悉uts语法',
\r\n
returnTodoTitle: '',
\r\n
returnTodoContent: '',
\r\n
genericDemoReturnTodoTitle: '',
\r\n
genericDemoReturnTodoContent: '',
\r\n
failErrCode: '',
\r\n
failErrDetailTips: '',
\r\n
failNumberErrCode: 0,
\r\n
successErrCode: -1,
\r\n
isUniTest: false
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
notify(content : string, title : string) {
\r\n
if (!this.isUniTest) {
\r\n
uni.showModal({
\r\n
title,
\r\n
content,
\r\n
showCancel: false
\r\n
})
\r\n
} else {
\r\n
console.log(title, content)
\r\n
}
\r\n
},
\r\n
async addTodo() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
const title = this.todoTitle
\r\n
const content = this.todoContent
\r\n
await todo.add<UTSJSONObject>(title, content).then((res : UTSJSONObject) => {
\r\n
this.returnTodoTitle = res['title'] as string
\r\n
this.returnTodoContent = res['content'] as string
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
console.log(err)
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async addTodoWithGeneric() : Promise<void> {
\r\n
type AddTodoResult = {
\r\n
title : string,
\r\n
content : string,
\r\n
showMessage : string
\r\n
}
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
const title = this.todoTitle
\r\n
const content = this.todoContent
\r\n
await todo.add<AddTodoResult>(title, content).then((res : AddTodoResult) => {
\r\n
this.genericDemoReturnTodoTitle = res.title
\r\n
this.genericDemoReturnTodoContent = res.content
\r\n
this.notify(res.showMessage, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
console.log(err)
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async randomFail() : Promise<void> {
\r\n
const todoObj = uniCloud.importObject('todo', {
\r\n
errorOptions: {
\r\n
retry: true
\r\n
}
\r\n
})
\r\n
await todoObj.randomFail().then((res : UTSJSONObject) => {
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async fail() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.fail().then((res : UTSJSONObject) => {
\r\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\r\n
console.log('todo.fail: ', res);
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
this.failErrCode = error.errCode as string
\r\n
const detail = error.detail
\r\n
if (detail != null && detail['tips'] != null) {
\r\n
this.failErrDetailTips = detail['tips'] as string
\r\n
}
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async failWithNumberErrCode() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.failWithNumberErrCode().then((res : UTSJSONObject) => {
\r\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\r\n
console.log('todo.fail: ', res);
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
this.failNumberErrCode = error.errCode as number
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async success() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.success().then((res : UTSJSONObject) => {
\r\n
this.successErrCode = res['errCode'] as number
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
}
\r\n
}
\r\n
}
\r\n\n
```
\n
:::"
},
"uploadFile"
:{
"name"
:
"## uploadFile(options) @uploadfile"
,
"description"
:
"上传文件到云存储"
,
"compatibility"
:
"### uploadFile
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | [UniCloudUploadFileOptions](#uniclouduploadfileoptions-values) | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| filePath | string | 是 | - | - | 文件路径 |
\n
@| cloudPath | string | 是 | - | - | 云端路径 |
\n
@| cloudPathAsRealPath | boolean | 否 | - | - | 是否以云端路径是否为真实路径保存上传的文件 |
\n\n
#### UniCloudUploadFileOptions 的方法 @uniclouduploadfileoptions-values
\n\n
#### onUploadProgress(options) @onuploadprogress
\n
上传进度回调
\n
##### onUploadProgress
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | **UniCloudUploadProgress** | 是 | - | - | 上传进度回调参数 |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| loaded | number | 是 | - | - | 已上传大小 |
\n
@| total | number | 是 | - | - | 总大小 |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| filePath | string | 是 | - | - | 文件路径 |
\n
@| fileID | string | 是 | - | - | 文件id |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudStorage.uploadFile)"
},
"getTempFileURL"
:{
"name"
:
"## getTempFileURL(options) @gettempfileurl"
,
"description"
:
"获取文件临时URL"
,
"compatibility"
:
"### getTempFileURL
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | **UniCloudGetTempFileURLOptions** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| fileList | Array
\\
<string
\\
> | 是 | - | - | 文件列表 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudGetTempFileURLResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| fileList | Array
\\
<**UniCloudGetTempFileURLResultItem**
\\
> | 是 | - | - | 文件列表 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| fileID | string | 是 | - | - | 文件id |
\n
@@| tempFileURL | string | 是 | - | - | 文件临时url |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudStorage.chooseAndUploadFile)"
},
"chooseAndUploadFile"
:{
"name"
:
"## chooseAndUploadFile(options) @chooseanduploadfile"
,
"description"
:
"选择并上传文件"
,
"compatibility"
:
"### chooseAndUploadFile
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | [UniCloudChooseAndUploadFileOptions](#unicloudchooseanduploadfileoptions-values) | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| sourceType | Array
\\
<Union
\\
>
\\
| null | 否 | - | - | |
\n
@| count | number
\\
| null | 否 | - | - | |
\n
@| sizeType | Array
\\
<Union
\\
>
\\
| null | 否 | - | - | |
\n
@| extension | Array
\\
<string
\\
>
\\
| null | 否 | - | - | |
\n
@| compressed | boolean
\\
| null | 否 | - | - | |
\n
@| maxDuration | number
\\
| null | 否 | - | - | |
\n
@| camera |
\"
front
\"
\\
|
\"
back
\"
| 否 | - | - | - |
\n
@| crop | ChooseImageCropOptions
\\
| null | 否 | - | - | |
\n
@| type |
\"
image
\"
\\
|
\"
video
\"
\\
|
\"
all
\"
| 是 | - | - | - |
\n\n
#### UniCloudChooseAndUploadFileOptions 的方法 @unicloudchooseanduploadfileoptions-values
\n\n
#### onChooseFile(arg) @onchoosefile
\n\n
##### onChooseFile
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | **UniCloudChooseFileResult** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| name | string | 是 | - | - | - |
\n
@@| path | string | 是 | - | - | - |
\n
@@| cloudPath | string | 是 | - | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | - | |
\n
@@| url | string
\\
| null | 否 | - | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n\n
#### onUploadProgress(arg) @onuploadprogress
\n\n
##### onUploadProgress
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | **UniCloudChooseAndUploadFileProgressEvent** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| index | number | 是 | - | - | - |
\n
@| loaded | number | 是 | - | - | - |
\n
@| total | number | 是 | - | - | - |
\n
@| tempFilePath | string | 是 | - | - | - |
\n
@| tempFile | **UniCloudChooseFileItem** | 是 | - | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| name | string | 是 | - | - | - |
\n
@@| path | string | 是 | - | - | - |
\n
@@| cloudPath | string | 是 | - | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | - | |
\n
@@| url | string
\\
| null | 否 | - | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | - | |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudChooseAndUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| name | string | 是 | - | - | - |
\n
@@| path | string | 是 | - | - | - |
\n
@@| cloudPath | string | 是 | - | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | - | |
\n
@@| url | string
\\
| null | 否 | - | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - | - |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudStorage.getTempFileURL)"
},
"cloudStorage"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/cloud-storage.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/cloud-storage/cloud-storage
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
uploadFile
\"
>选择文件上传</button>
\n
<button type=
\"
primary
\"
@click=
\"
chooseAndUploadFile
\"
>一个接口选择文件并上传</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '云存储'
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
},
\n
methods: {
\n
uploadFile: function () {
\n
uni.chooseImage({
\n
count: 1,
\n
success(res) : void {
\n
uni.showLoading({
\n
title: '上传中...'
\n
})
\n
const tempFilePath = res.tempFilePaths[0]
\n
uniCloud.uploadFile({
\n
filePath: tempFilePath,
\n
cloudPath: 'test.jpg'
\n
})
\n
.then(function (res) {
\n
uni.hideLoading()
\n
console.log(res)
\n
uni.showModal({
\n
content: '上传成功',
\n
showCancel: false
\n
});
\n
})
\n
.catch(function (err : any | null) {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
uni.showModal({
\n
content: '上传失败,' + error.errMsg,
\n
showCancel: false
\n
});
\n
})
\n
// .finally((_: number) : void => {
\n
// uni.hideLoading()
\n
// })
\n
},
\n
fail(err) : void {
\n
console.error('chooseImage fail: ', err)
\n
}
\n
})
\n
},
\n
chooseAndUploadFile() {
\n
uniCloud.chooseAndUploadFile({
\n
type: 'image'
\n
}).then(function (res) {
\n
uni.hideLoading()
\n
console.log(res)
\n
uni.showModal({
\n
content: '上传成功',
\n
showCancel: false
\n
});
\n
})
\n
.catch(function (err : any | null) {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
uni.showModal({
\n
content: '上传失败,' + error.errMsg,
\n
showCancel: false
\n
});
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"databaseForJQL"
:{
"name"
:
"## databaseForJQL() @databaseforjql"
,
"description"
:
"获取数据库操作实例"
,
"compatibility"
:
"### databaseForJQL
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.91,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Database](#database-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| command | any | 是 | - | - | - |
\n
@| Geo | any | 是 | - | - | - |
\n
#### Database 的方法 @database-values
\n\n
#### collection(args?) @collection
\n\n
##### collection
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Collection](#collection-values) |
\n\n
###### Collection 的方法 @collection-values
\n\n
###### where(condition) @where
\n\n
###### where
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| condition | any | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n
###### UniCloudDBFilter 的方法 @uniclouddbfilter-values
\n\n
###### get(arg?) @get
\n\n
###### get
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | any
\\
| null | 否 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBGetResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| data | Array
\\
<any
\\
> | 是 | - | - | etResult = { /** |
\n
@| count | number
\\
| null | 否 | - | - | JSONObject>;<br/> /** |
\n
@| requestId | string | 否 | - | - | ber
\\
| null; / |
\n\n
###### count() @count
\n\n
###### count
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBCountResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| total | number | 是 | - | - | ntResult = { /** |
\n
@| requestId | string | 否 | - | - | al: number; / |
\n\n
###### update(data) @update
\n\n
###### update
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| data | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBUpdateResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| updated | number | 是 | - | - | teResult = { /** |
\n
@| requestId | string | 否 | - | - | ted: number; / |
\n\n
###### remove() @remove
\n\n
###### remove
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBRemoveResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| deleted | number | 是 | - | - | veResult = { /** |
\n
@| requestId | string | 否 | - | - | ted: number; / |
\n\n
###### getTemp() @gettemp
\n\n
###### getTemp
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n
###### where(condition) @where
\n\n
###### where
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| condition | any | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### doc(docId) @doc
\n\n
###### doc
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| docId | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### field(filed) @field
\n\n
###### field
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| filed | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n
###### UniCloudDBQuery 的方法 @uniclouddbquery-values
\n\n
###### get(arg?) @get
\n\n
###### get
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | any
\\
| null | 否 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n
###### count() @count
\n\n
###### count
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n
###### getTemp() @gettemp
\n\n
###### getTemp
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n
###### field(filed) @field
\n\n
###### field
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| filed | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### skip(num) @skip
\n\n
###### skip
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### limit(num) @limit
\n\n
###### limit
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### orderBy(order) @orderby
\n\n
###### orderBy
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| order | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### groupBy(field) @groupby
\n\n
###### groupBy
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### groupField(field) @groupfield
\n\n
###### groupField
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### distinct(field) @distinct
\n\n
###### distinct
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### geoNear(options) @geonear
\n\n
###### geoNear
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n
\n\n
###### skip(num) @skip
\n\n
###### skip
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### limit(num) @limit
\n\n
###### limit
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### orderBy(order) @orderby
\n\n
###### orderBy
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| order | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### groupBy(field) @groupby
\n\n
###### groupBy
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### groupField(field) @groupfield
\n\n
###### groupField
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### distinct(field) @distinct
\n\n
###### distinct
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### geoNear(options) @geonear
\n\n
###### geoNear
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n
\n\n
###### doc(docId) @doc
\n\n
###### doc
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| docId | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### aggregate() @aggregate
\n\n
###### aggregate
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### foreignKey(foreignKey) @foreignkey
\n\n
###### foreignKey
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| foreignKey | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### add(data) @add
\n\n
###### add
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| data | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBAddResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| id | string | 是 | - | - | ddResult = { /** |
\n
@| requestId | string | 否 | - | - | string; / |
\n\n
###### get(arg?) @get
\n\n
###### get
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | any
\\
| null | 否 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n
###### count() @count
\n\n
###### count
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n
###### getTemp() @gettemp
\n\n
###### getTemp
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n
###### field(filed) @field
\n\n
###### field
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| filed | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### skip(num) @skip
\n\n
###### skip
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### limit(num) @limit
\n\n
###### limit
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### orderBy(order) @orderby
\n\n
###### orderBy
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| order | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n
\n\n
#### multiSend(args?) @multisend
\n
合并查询请求
\n
##### multiSend
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 4.16 | 4.11 |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBMultiSendResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| dataList | Array
\\
<**UniCloudDBMultiSendResultItem**
\\
> | 是 | - | - | SendResult = { |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| errCode | any | 是 | - | - | ResultItem = { /** 错误码,可 |
\n
@@| errMsg | string | 是 | - | - | errCode : any |
\n
@@| data | Array
\\
<any
\\
> | 否 | - | - | Msg : stri |
\n
@| requestId | string | 否 | - | - | ndResultItem[
\\
] |
\n
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.database.databaseForJQL)"
},
"database"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/database.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/database/database
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
dbAdd
\"
>新增单条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbBatchAdd
\"
>新增多条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbUpdate
\"
>更新数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGet
\"
>where传字符串获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGetWithCommand
\"
>where传对象获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbRemove
\"
>删除数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookupInit
\"
>初始化联表查询数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookup
\"
>联表查询</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbMultiSend
\"
>合并查询查询</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: 'ClientDB',
\n
addId: '',
\n
batchAddIds: [] as Array<string>,
\n
batchAddinserted: 0,
\n
updateUpdated: 0,
\n
getData: [] as Array<UTSJSONObject>,
\n
getWithCommandData: [] as Array<UTSJSONObject>,
\n
removeDeleted: 0,
\n
lookupData: [] as Array<UTSJSONObject>,
\n
multiSendSuccessCount: 0,
\n
isUniTest: false
\n
}
\n
},
\n
computed: {
\n
dataTag() : string {
\n
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async dbAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add({
\n
num: 1,
\n
tag: this.dataTag,
\n
date: new Date()
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.addId = res.id
\n
this.notify(`新增成功,id: ${res.id}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbBatchAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add([{
\n
num: 2,
\n
tag: this.dataTag,
\n
}, {
\n
num: 3,
\n
tag: this.dataTag,
\n
}])
\n
.then((res) => {
\n
uni.hideLoading()
\n
console.log(res)
\n
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
\n
this.batchAddIds = res.ids
\n
this.batchAddinserted = res.inserted
\n
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGet() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGetWithCommand() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where({
\n
num: db.command.gt(1),
\n
tag: this.dataTag
\n
})
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getWithCommandData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbUpdate() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.update({
\n
num: 4
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.updateUpdated = res.updated
\n
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbRemove() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.remove()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.removeDeleted = res.deleted
\n
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookupInit() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
.then(() : Promise<UniCloudDBRemoveResult> => {
\n
return db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('local')
\n
.add([{
\n
id:
\"
local_1
\"
,
\n
name:
\"
local_1_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_1
\"\n
}, {
\n
id:
\"
local_2
\"
,
\n
name:
\"
local_2_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_2
\"\n
}])
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('foreign')
\n
.add([{
\n
id:
\"
foreign_1
\"
,
\n
name:
\"
foreign_1_name
\"
,
\n
tag: this.dataTag
\n
}, {
\n
id:
\"
foreign_2
\"
,
\n
name:
\"
foreign_2_name
\"
,
\n
tag: this.dataTag
\n
}])
\n
})
\n
.then((_) : void => {
\n
uni.hideLoading()
\n
this.notify('数据初始化成功', '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
console.error(err)
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookup() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
const local = db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
const foreign = db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
await db.collection(local, foreign)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.lookupData = res.data
\n
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbMultiSend() : Promise<void> {
\n
const db = uniCloud.databaseForJQL()
\n
const temp1 = db.collection('type')
\n
.where(
\n
'tag ==
\"
default-tag
\"
'
\n
).getTemp()
\n
const temp2 = db.collection('type')
\n
.where(
\n
'tag ==
\"
default-tag
\"
'
\n
).getTemp()
\n
await db.multiSend(temp1, temp2)
\n
.then<void>(res => {
\n
uni.hideLoading()
\n
let successCount = 0
\n
for (let i = 0; i < res.dataList.length; i++) {
\n
const item = res.dataList[i]
\n
if(item.errCode == 0) {
\n
console.log(`第${i}个请求查询到${item.data!.length}条数据`)
\n
successCount++
\n
} else {
\n
console.error(`第${i}个请求查询失败,错误信息:${item.data!.length}`)
\n
}
\n
}
\n
this.multiSendSuccessCount = successCount
\n
this.notify(`合并查询成功,成功查询的语句条数为:${successCount}`, '提示')
\n
})
\n
.catch<void>((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
console.error(err)
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"onResponse"
:{
"name"
:
"## onResponse(callback) @onresponse"
,
"description"
:
"监听响应事件"
,
"compatibility"
:
"### onResponse
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.onResponse)"
},
"offResponse"
:{
"name"
:
"## offResponse(callback) @offresponse"
,
"description"
:
"移除响应事件监听"
,
"compatibility"
:
"### offResponse
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.offResponse)"
},
"onRefreshToken"
:{
"name"
:
"## onRefreshToken(callback) @onrefreshtoken"
,
"description"
:
"监听token刷新事件"
,
"compatibility"
:
"### onRefreshToken
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.onRefreshToken)"
},
"offRefreshToken"
:{
"name"
:
"## offRefreshToken(callback) @offrefreshtoken"
,
"description"
:
"移除token刷新事件监听"
,
"compatibility"
:
"### offRefreshToken
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.offRefreshToken)"
},
"getCurrentUserInfo"
:{
"name"
:
"## getCurrentUserInfo() @getcurrentuserinfo"
,
"description"
:
"获取token内缓存的用户信息"
,
"compatibility"
:
"### getCurrentUserInfo
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| **UniCloudUserInfo** |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| uid | string
\\
| null | 否 | - | - | UserInfo = {<br/> / |
\n
@| role | Array
\\
<string
\\
> | 是 | - | - | ing
\\
| null; / |
\n
@| permission | Array
\\
<string
\\
> | 是 | - | - | ay
\\
<string>; / |
\n
@| tokenExpired | number | 是 | - | - | ay
\\
<string>; /** |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.getCurrentUserInfo)"
}}
\ No newline at end of file
{
"uniCloud_props"
:{
"name"
:
"# uniCloud"
,
"description"
:
""
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| config | **UniCloudInitOptions** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| provider | string | 是 | - | - | 服务商,目前支持 aliyun、tencent、alipay |
\n
@| spaceName | string | 否 | - | - | 服务空间名 |
\n
@| spaceId | string | 是 | - | - | 服务空间id |
\n
@| clientSecret | string | 否 | - | - | 阿里云clientSecret |
\n
@| endpoint | string | 否 | - | - | 阿里云endpoint |
\n
@| spaceAppId | string | 否 | - | - | 支付宝云spaceAppId |
\n
@| accessKey | string | 否 | - | - | 支付宝云accessKey |
\n
@| secretKey | string | 否 | - | - | 支付宝云secretKey |
\n
@| wsEndpoint | string | 否 | - | - | 支付宝云 WebSocket Endpoint |
\n
| mixinDatacom | any | 是 | - | - | - |
\n
"
,
"returnValue"
:
""
,
"compatibility"
:
""
,
"tutorial"
:
""
},
"callFunction"
:{
"name"
:
"## callFunction(options) @callfunction"
,
"description"
:
"请求云函数"
,
"compatibility"
:
"### callFunction 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | **UniCloudCallFunctionOptions** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| name | string ([string.CloudFunctionString](/uts/data-type.md#ide-string)) | 是 | - | - | 云函数名 |
\n
@| data | any | 否 | - | - | 云函数参数 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudCallFunctionResult
\\
<T>](#unicloudcallfunctionresult-values)> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| result | T | 是 | - | - | 云函数返回结果 |
\n
@| requestId | string | 否 | - | - | 云函数请求id |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudFunction.callFunction)"
},
"cloudFunction"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/cloud-function.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/cloud-function/cloud-function
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
callFunction
\"
>请求云函数</button>
\n
<button type=
\"
primary
\"
@click=
\"
callFunctionWithGeneric
\"
>请求云函数传入泛型</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '请求云函数',
\n
callFunctionResult: {},
\n
callFunctionError: {},
\n
genericDemoShowMessage: '',
\n
isUniTest: false
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
if (this.isUniTest) {
\n
uni.hideToast()
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async callFunctionWithGeneric() : Promise<void> {
\n
type EchoCfResult = {
\n
showMessage: string
\n
}
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction<EchoCfResult>({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
uni.hideLoading()
\n
this.genericDemoShowMessage = result.showMessage
\n
this.notify(result.showMessage, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async callFunction() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
await uniCloud.callFunction({
\n
name: 'echo-cf',
\n
data: {
\n
num: 1,
\n
str: 'ABC'
\n
}
\n
}).then(res => {
\n
const result = res.result
\n
this.callFunctionResult = result
\n
console.log(JSON.stringify(result))
\n
uni.hideLoading()
\n
this.notify(result['showMessage'] as string, '提示')
\n
}).catch((err : any | null) => {
\n
const error = err as UniCloudError
\n
this.callFunctionError = {
\n
errCode: error.errCode,
\n
errMsg: error.errMsg
\n
}
\n
uni.hideLoading()
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"importObject"
:{
"name"
:
"## importObject(objectName, options?) @importobject"
,
"description"
:
"引用云对象"
,
"compatibility"
:
"### importObject 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| objectName | string ([string.CloudObjectString](/uts/data-type.md#ide-string)) | 是 | - | - | - |
\n
| options | **UniCloudImportObjectOptions** | 否 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| customUI | boolean
\\
| null | 否 | - | - | 是否移除自动展示的ui |
\n
@| loadingOptions | **UniCloudImportObjectLoadingOptions**
\\
| null | 否 | - | - | loading界面配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| title | string
\\
| null | 否 | - | - | 加载框标题 |
\n
@@| mask | boolean
\\
| null | 否 | - | - | 加载框是否显示mask |
\n
@| errorOptions | **UniCloudImportObjectErrorOptions**
\\
| null | 否 | - | - | 错误提示配置 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| type | string
\\
| null | 否 | - | - | 错误提示类型,可以是modal或者toast |
\n
@@| retry | boolean
\\
| null | 否 | - | - | 是否显示重试按钮 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudCloudObjectCaller](#unicloudcloudobjectcaller-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| _obj | [InternalUniCloudCloudObject](#internalunicloudcloudobject-values) | 是 | - | - | - |
\n
##### InternalUniCloudCloudObject 的方法 @internalunicloudcloudobject-values
\n\n
##### callMethod
\\
<T = UTSJSONObject>(methodName: string, args: Array
\\
<any
\\
| null>): Promise
\\
<T>; @callmethod
\n\n
###### callMethod 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| methodName | string | 是 | - | - | - |
\n
| args | Array
\\
<any
\\
| null
\\
> | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<T> |
\n
\n\n
#### UniCloudCloudObjectCaller 的方法 @unicloudcloudobjectcaller-values
\n\n
#### protected _getArgs(...args: Array
\\
<any
\\
| null>): Array
\\
<any
\\
| null>; @_getargs
\n\n
##### _getArgs 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| args | Array
\\
<any
\\
| null
\\
> | 否 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Array
\\
<any
\\
| null
\\
> |
\n
\n
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudObject.importObject)"
},
"cloudObject"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/cloud-object.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/cloud-object/cloud-object
\n
>Template
\n
```vue
\n
<template>
\r\n
<!-- #ifdef APP -->
\r\n
<scroll-view class=
\"
page-scroll-view
\"
>
\r\n
<!-- #endif -->
\r\n
<view>
\r\n
<page-head :title=
\"
title
\"
></page-head>
\r\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
addTodo
\"
>添加Todo</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
addTodoWithGeneric
\"
>
\r\n
添加Todo传入泛型
\r\n
</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
randomFail
\"
>随机触发失败重试</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
fail
\"
>云对象失败调用</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
failWithNumberErrCode
\"
>
\r\n
云对象数字错误码
\r\n
</button>
\r\n
</view>
\r\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\r\n
<button type=
\"
primary
\"
@tap=
\"
success
\"
>云对象成功调用</button>
\r\n
</view>
\r\n
</view>
\r\n
</view>
\r\n
<!-- #ifdef APP -->
\r\n
</scroll-view>
\r\n
<!-- #endif -->
\r\n
</template>
\r\n\r\n\r\n\r\n
<style></style>
\n\n
```
\n
>Script
\n
```uts
\n\r\n
export default {
\r\n
data() {
\r\n
return {
\r\n
title: '请求云对象',
\r\n
todoTitle: '学习编程',
\r\n
todoContent: '熟悉uts语法',
\r\n
returnTodoTitle: '',
\r\n
returnTodoContent: '',
\r\n
genericDemoReturnTodoTitle: '',
\r\n
genericDemoReturnTodoContent: '',
\r\n
failErrCode: '',
\r\n
failErrDetailTips: '',
\r\n
failNumberErrCode: 0,
\r\n
successErrCode: -1,
\r\n
isUniTest: false
\r\n
}
\r\n
},
\r\n
methods: {
\r\n
notify(content : string, title : string) {
\r\n
if (!this.isUniTest) {
\r\n
uni.showModal({
\r\n
title,
\r\n
content,
\r\n
showCancel: false
\r\n
})
\r\n
} else {
\r\n
console.log(title, content)
\r\n
}
\r\n
},
\r\n
async addTodo() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
const title = this.todoTitle
\r\n
const content = this.todoContent
\r\n
await todo.add<UTSJSONObject>(title, content).then((res : UTSJSONObject) => {
\r\n
this.returnTodoTitle = res['title'] as string
\r\n
this.returnTodoContent = res['content'] as string
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
console.log(err)
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async addTodoWithGeneric() : Promise<void> {
\r\n
type AddTodoResult = {
\r\n
title : string,
\r\n
content : string,
\r\n
showMessage : string
\r\n
}
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
const title = this.todoTitle
\r\n
const content = this.todoContent
\r\n
await todo.add<AddTodoResult>(title, content).then((res : AddTodoResult) => {
\r\n
this.genericDemoReturnTodoTitle = res.title
\r\n
this.genericDemoReturnTodoContent = res.content
\r\n
this.notify(res.showMessage, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
console.log(err)
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async randomFail() : Promise<void> {
\r\n
const todoObj = uniCloud.importObject('todo', {
\r\n
errorOptions: {
\r\n
retry: true
\r\n
}
\r\n
})
\r\n
await todoObj.randomFail().then((res : UTSJSONObject) => {
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async fail() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.fail().then((res : UTSJSONObject) => {
\r\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\r\n
console.log('todo.fail: ', res);
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
this.failErrCode = error.errCode as string
\r\n
const detail = error.detail
\r\n
if (detail != null && detail['tips'] != null) {
\r\n
this.failErrDetailTips = detail['tips'] as string
\r\n
}
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async failWithNumberErrCode() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.failWithNumberErrCode().then((res : UTSJSONObject) => {
\r\n
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
\r\n
console.log('todo.fail: ', res);
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
this.failNumberErrCode = error.errCode as number
\r\n
console.error(error)
\r\n
})
\r\n
},
\r\n
async success() : Promise<void> {
\r\n
const todo = uniCloud.importObject('todo', {
\r\n
customUI: this.isUniTest
\r\n
})
\r\n
await todo.success().then((res : UTSJSONObject) => {
\r\n
this.successErrCode = res['errCode'] as number
\r\n
this.notify(res['showMessage'] as string, '提示')
\r\n
}).catch((err : any | null) => {
\r\n
const error = err as UniCloudError
\r\n
console.error(error)
\r\n
})
\r\n
}
\r\n
}
\r\n
}
\r\n\n
```
\n
:::"
},
"uploadFile"
:{
"name"
:
"## uploadFile(options) @uploadfile"
,
"description"
:
"上传文件到云存储"
,
"compatibility"
:
"### uploadFile 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | [UniCloudUploadFileOptions](#uniclouduploadfileoptions-values) | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| filePath | string | 是 | - | - | 文件路径 |
\n
@| cloudPath | string | 是 | - | - | 云端路径 |
\n
@| cloudPathAsRealPath | boolean | 否 | - | - | 是否以云端路径是否为真实路径保存上传的文件 |
\n\n
#### UniCloudUploadFileOptions 的方法 @uniclouduploadfileoptions-values
\n\n
#### (options: UniCloudUploadProgress) => any @onuploadprogress
\n
上传进度回调
\n
##### onUploadProgress 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | **UniCloudUploadProgress** | 是 | - | - | 上传进度回调参数 |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| loaded | number | 是 | - | - | 已上传大小 |
\n
@| total | number | 是 | - | - | 总大小 |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| filePath | string | 是 | - | - | 文件路径 |
\n
@| fileID | string | 是 | - | - | 文件id |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudStorage.uploadFile)"
},
"getTempFileURL"
:{
"name"
:
"## getTempFileURL(options) @gettempfileurl"
,
"description"
:
"获取文件临时URL"
,
"compatibility"
:
"### getTempFileURL 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | **UniCloudGetTempFileURLOptions** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| fileList | Array
\\
<string
\\
> | 是 | - | - | 文件列表 |
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudGetTempFileURLResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| fileList | Array
\\
<**UniCloudGetTempFileURLResultItem**
\\
> | 是 | - | - | 文件列表 |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| fileID | string | 是 | - | - | 文件id |
\n
@@| tempFileURL | string | 是 | - | - | 文件临时url |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudStorage.chooseAndUploadFile)"
},
"chooseAndUploadFile"
:{
"name"
:
"## chooseAndUploadFile(options) @chooseanduploadfile"
,
"description"
:
"选择并上传文件"
,
"compatibility"
:
"### chooseAndUploadFile 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | [UniCloudChooseAndUploadFileOptions](#unicloudchooseanduploadfileoptions-values) | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| sourceType | Array
\\
<Union
\\
>
\\
| null | 否 | - | - | |
\n
@| count | number
\\
| null | 否 | - | - | |
\n
@| sizeType | Array
\\
<Union
\\
>
\\
| null | 否 | - | - | |
\n
@| extension | Array
\\
<string
\\
>
\\
| null | 否 | - | - | |
\n
@| compressed | boolean
\\
| null | 否 | - | - | |
\n
@| maxDuration | number
\\
| null | 否 | - | - | |
\n
@| camera |
\"
front
\"
\\
|
\"
back
\"
| 否 | - | - | - |
\n
@| crop | ChooseImageCropOptions
\\
| null | 否 | - | - | |
\n
@| type |
\"
image
\"
\\
|
\"
video
\"
\\
|
\"
all
\"
| 是 | - | - | - |
\n\n
#### UniCloudChooseAndUploadFileOptions 的方法 @unicloudchooseanduploadfileoptions-values
\n\n
#### ;
\n
onChooseFile?: (arg: UniCloudChooseFileRe @onchoosefile
\n\n
##### onChooseFile 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | **UniCloudChooseFileResult** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| name | string | 是 | - | - | - |
\n
@@| path | string | 是 | - | - | - |
\n
@@| cloudPath | string | 是 | - | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | - | |
\n
@@| url | string
\\
| null | 否 | - | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n\n
#### onUploadProgress?: (arg: UniCloudChooseAndUploadFileProgressE @onuploadprogress
\n\n
##### onUploadProgress 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | **UniCloudChooseAndUploadFileProgressEvent** | 是 | - | - | - |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| index | number | 是 | - | - | - |
\n
@| loaded | number | 是 | - | - | - |
\n
@| total | number | 是 | - | - | - |
\n
@| tempFilePath | string | 是 | - | - | - |
\n
@| tempFile | **UniCloudChooseFileItem** | 是 | - | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| name | string | 是 | - | - | - |
\n
@@| path | string | 是 | - | - | - |
\n
@@| cloudPath | string | 是 | - | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | - | |
\n
@@| url | string
\\
| null | 否 | - | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | - | |
\n\n
##### 返回值
\n\n
| 类型 | 必备 |
\n
| :- | :- |
\n
| void
\\
| null | 否 |
\n
\n
"
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudChooseAndUploadFileResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| tempFiles | Array
\\
<**UniCloudChooseFileItem**
\\
> | 是 | - | - | - |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| name | string | 是 | - | - | - |
\n
@@| path | string | 是 | - | - | - |
\n
@@| cloudPath | string | 是 | - | - | - |
\n
@@| cloudPathAsRealPath | boolean
\\
| null | 否 | - | - | |
\n
@@| url | string
\\
| null | 否 | - | - | |
\n
@@| errMsg | string
\\
| null | 否 | - | - | |
\n
@| tempFilePaths | Array
\\
<string
\\
> | 是 | - | - | - |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.cloudStorage.getTempFileURL)"
},
"cloudStorage"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/cloud-storage.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/cloud-storage/cloud-storage
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
uploadFile
\"
>选择文件上传</button>
\n
<button type=
\"
primary
\"
@click=
\"
chooseAndUploadFile
\"
>一个接口选择文件并上传</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: '云存储'
\n
}
\n
},
\n
onLoad() {
\n
},
\n
onUnload() {
\n
},
\n
methods: {
\n
uploadFile: function () {
\n
uni.chooseImage({
\n
count: 1,
\n
success(res) : void {
\n
uni.showLoading({
\n
title: '上传中...'
\n
})
\n
const tempFilePath = res.tempFilePaths[0]
\n
uniCloud.uploadFile({
\n
filePath: tempFilePath,
\n
cloudPath: 'test.jpg'
\n
})
\n
.then(function (res) {
\n
uni.hideLoading()
\n
console.log(res)
\n
uni.showModal({
\n
content: '上传成功',
\n
showCancel: false
\n
});
\n
})
\n
.catch(function (err : any | null) {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
uni.showModal({
\n
content: '上传失败,' + error.errMsg,
\n
showCancel: false
\n
});
\n
})
\n
// .finally((_: number) : void => {
\n
// uni.hideLoading()
\n
// })
\n
},
\n
fail(err) : void {
\n
console.error('chooseImage fail: ', err)
\n
}
\n
})
\n
},
\n
chooseAndUploadFile() {
\n
uniCloud.chooseAndUploadFile({
\n
type: 'image'
\n
}).then(function (res) {
\n
uni.hideLoading()
\n
console.log(res)
\n
uni.showModal({
\n
content: '上传成功',
\n
showCancel: false
\n
});
\n
})
\n
.catch(function (err : any | null) {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
uni.showModal({
\n
content: '上传失败,' + error.errMsg,
\n
showCancel: false
\n
});
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"databaseForJQL"
:{
"name"
:
"## databaseForJQL() @databaseforjql"
,
"description"
:
"获取数据库操作实例"
,
"compatibility"
:
"### databaseForJQL 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.91,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Database](#database-values) |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| command | any | 是 | - | - | - |
\n
@| Geo | any | 是 | - | - | - |
\n
#### Database 的方法 @database-values
\n\n
#### t: UniCloudUnified);
\n
collection(...args: Arra @collection
\n\n
##### collection 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [Collection](#collection-values) |
\n\n
###### Collection 的方法 @collection-values
\n\n
###### onList: Array
\\
<any>);
\n
where(condition: any @where
\n\n
###### where 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| condition | any | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n\n
###### UniCloudDBFilter 的方法 @uniclouddbfilter-values
\n\n
###### ed, stages: Stages);
\n
get(arg?: UTSJSONObject
\\
| null): Promise
\\
<U @get
\n\n
###### get 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | any
\\
| null | 否 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBGetResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| data | Array
\\
<any
\\
> | 是 | - | - | etResult = {<br/> /** |
\n
@| count | number
\\
| null | 否 | - | - | JSONObject>;<br/> /** |
\n
@| requestId | string | 否 | - | - | ber
\\
| null;<br/> / |
\n\n
###### niCloudDBGetResult>;
\n
count(): Promise
\\
<Uni @count
\n\n
###### count 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBCountResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| total | number | 是 | - | - | ntResult = {<br/> /** |
\n
@| requestId | string | 否 | - | - | al: number;<br/> / |
\n\n
###### CloudDBCountResult>;
\n
update(data: UTSJSONObject): Promise
\\
<UniC @update
\n\n
###### update 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| data | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBUpdateResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| updated | number | 是 | - | - | teResult = {<br/> /** |
\n
@| requestId | string | 否 | - | - | ted: number;<br/> / |
\n\n
###### loudDBUpdateResult>;
\n
remove(): Promise
\\
<UniC @remove
\n\n
###### remove 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBRemoveResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| deleted | number | 是 | - | - | veResult = {<br/> /** |
\n
@| requestId | string | 否 | - | - | ted: number;<br/> / |
\n\n
###### loudDBRemoveResult>;
\n
getTe @gettemp
\n\n
###### getTemp 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n
###### mp(): UTSJSONObject;
\n
where(condition: any @where
\n\n
###### where 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| condition | any | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### ): UniCloudDBFilter;
\n
doc(docId: string @doc
\n\n
###### doc 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| docId | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### ): UniCloudDBFilter;
\n
field(filed: strin @field
\n\n
###### field 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| filed | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n\n
###### UniCloudDBQuery 的方法 @uniclouddbquery-values
\n\n
###### ed, stages: Stages);
\n
get(arg?: UTSJSONObject
\\
| null): Promise
\\
<U @get
\n\n
###### get 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | any
\\
| null | 否 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n
###### niCloudDBGetResult>;
\n
count(): Promise
\\
<Uni @count
\n\n
###### count 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n
###### CloudDBCountResult>;
\n
getTe @gettemp
\n\n
###### getTemp 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n
###### mp(): UTSJSONObject;
\n
field(filed: strin @field
\n\n
###### field 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| filed | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
skip(num: numbe @skip
\n\n
###### skip 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### r): UniCloudDBQuery;
\n
limit(num: numbe @limit
\n\n
###### limit 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### r): UniCloudDBQuery;
\n
orderBy(order: strin @orderby
\n\n
###### orderBy 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| order | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
groupBy(field: strin @groupby
\n\n
###### groupBy 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
groupField(field: strin @groupfield
\n\n
###### groupField 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
distinct(field: strin @distinct
\n\n
###### distinct 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
geoNear(options: UTSJSONObjec @geonear
\n\n
###### geoNear 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n
\n\n
###### g): UniCloudDBQuery;
\n
skip(num: numbe @skip
\n\n
###### skip 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### r): UniCloudDBQuery;
\n
limit(num: numbe @limit
\n\n
###### limit 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### r): UniCloudDBQuery;
\n
orderBy(order: strin @orderby
\n\n
###### orderBy 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| order | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
groupBy(field: strin @groupby
\n\n
###### groupBy 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
groupField(field: strin @groupfield
\n\n
###### groupField 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
distinct(field: strin @distinct
\n\n
###### distinct 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| field | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
geoNear(options: UTSJSONObjec @geonear
\n\n
###### geoNear 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| options | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n
\n\n
###### ): UniCloudDBFilter;
\n
doc(docId: string @doc
\n\n
###### doc 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| docId | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### ): UniCloudDBFilter;
\n
aggregate( @aggregate
\n\n
###### aggregate 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### ): UniCloudDBFilter;
\n
foreignKey(foreignKey: string @foreignkey
\n\n
###### foreignKey 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| foreignKey | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBFilter](#uniclouddbfilter-values) |
\n
\n\n
###### ): UniCloudDBFilter;
\n
add(data: UTSJSONObject): Promise
\\
<U @add
\n\n
###### add 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| data | any | 是 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBAddResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| id | string | 是 | - | - | ddResult = {<br/> /** |
\n
@| requestId | string | 否 | - | - | string;<br/> / |
\n\n
###### udDBBatchAddResult>;
\n
get(arg?: UTSJSONObject
\\
| null): Promise
\\
<U @get
\n\n
###### get 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| arg | any
\\
| null | 否 | - | - | |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBGetResult](#uniclouddbgetresult-values)> |
\n
\n\n
###### niCloudDBGetResult>;
\n
count(): Promise
\\
<Uni @count
\n\n
###### count 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<[UniCloudDBCountResult](#uniclouddbcountresult-values)> |
\n
\n\n
###### CloudDBCountResult>;
\n
getTe @gettemp
\n\n
###### getTemp 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| any |
\n
\n\n
###### mp(): UTSJSONObject;
\n
field(filed: strin @field
\n\n
###### field 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| filed | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### g): UniCloudDBQuery;
\n
skip(num: numbe @skip
\n\n
###### skip 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### r): UniCloudDBQuery;
\n
limit(num: numbe @limit
\n\n
###### limit 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| num | number | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n\n
###### r): UniCloudDBQuery;
\n
orderBy(order: strin @orderby
\n\n
###### orderBy 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| - | - | - |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| order | string | 是 | - | - | - |
\n\n
###### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| [UniCloudDBQuery](#uniclouddbquery-values) |
\n
\n
\n\n
#### ypeof UniCloudDBGeo;
\n
/**
\n
* 合并查询请求
\n
* @description 合并查询请求
\n
* @uniPlatform {
\n
*
\"
app
\"
: {
\n
*
\"
android
\"
: {
\n
*
\"
osVer
\"
:
\"
5.0
\"
,
\n
*
\"
uniVer
\"
:
\"
√
\"
,
\n
*
\"
unixVer
\"
:
\"
4.16
\"\n
* },
\n
*
\"
ios
\"
: {
\n
*
\"
uniVer
\"
:
\"
√
\"
,
\n
*
\"
unixVer
\"
:
\"
4.11
\"\n
* }
\n
* },
\n
*
\"
web
\"
: {
\n
*
\"
uniVer
\"
:
\"
√
\"
,
\n
*
\"
unixVer
\"
:
\"
4.0
\"\n
* }
\n
* }
\n
*/
\n
multiSend(...args: Array
\\
<UTSJSONObject>): Promise
\\
<UniClou @multisend
\n
合并查询请求
\n
##### multiSend 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 4.16 | 4.11 |
\n\n
##### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| args | Array
\\
<any
\\
> | 否 | - | - | - |
\n\n
##### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| Promise
\\
<**UniCloudDBMultiSendResult**> |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| dataList | Array
\\
<**UniCloudDBMultiSendResultItem**
\\
> | 是 | - | - | SendResult = { |
\n
@@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@@| :- | :- | :- | :- | :-: | :- |
\n
@@| errCode | any | 是 | - | - | ResultItem = {<br/> /**<br/>错误码,可 |
\n
@@| errMsg | string | 是 | - | - | errCode : any |
\n
@@| data | Array
\\
<any
\\
> | 否 | - | - | Msg : stri |
\n
@| requestId | string | 否 | - | - | ndResultItem[
\\
] |
\n
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.database.databaseForJQL)"
},
"database"
:{
"example"
:
"## 示例
\n
> [hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/unicloud/unicloud/database.uvue)
\n
::: preview https://hellouniappx.dcloud.net.cn/web/#/pages/API/database/database
\n
>Template
\n
```vue
\n
<template>
\n
<!-- #ifdef APP -->
\n
<scroll-view class=
\"
page-scroll-view
\"
>
\n
<!-- #endif -->
\n
<view>
\n
<page-head :title=
\"
title
\"
></page-head>
\n
<view class=
\"
uni-padding-wrap uni-common-mt
\"
>
\n
<view class=
\"
uni-btn-v uni-common-mt
\"
>
\n
<button type=
\"
primary
\"
@click=
\"
dbAdd
\"
>新增单条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbBatchAdd
\"
>新增多条数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbUpdate
\"
>更新数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGet
\"
>where传字符串获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbGetWithCommand
\"
>where传对象获取数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbRemove
\"
>删除数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookupInit
\"
>初始化联表查询数据</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbLookup
\"
>联表查询</button>
\n
<button type=
\"
primary
\"
@click=
\"
dbMultiSend
\"
>合并查询查询</button>
\n
</view>
\n
</view>
\n
</view>
\n
<!-- #ifdef APP -->
\n
</scroll-view>
\n
<!-- #endif -->
\n
</template>
\n\n\n\n
<style>
\n
</style>
\n\n
```
\n
>Script
\n
```uts
\n\n
export default {
\n
data() {
\n
return {
\n
title: 'ClientDB',
\n
addId: '',
\n
batchAddIds: [] as Array<string>,
\n
batchAddinserted: 0,
\n
updateUpdated: 0,
\n
getData: [] as Array<UTSJSONObject>,
\n
getWithCommandData: [] as Array<UTSJSONObject>,
\n
removeDeleted: 0,
\n
lookupData: [] as Array<UTSJSONObject>,
\n
multiSendSuccessCount: 0,
\n
isUniTest: false
\n
}
\n
},
\n
computed: {
\n
dataTag() : string {
\n
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
\n
}
\n
},
\n
methods: {
\n
notify(content : string, title : string) {
\n
if (!this.isUniTest) {
\n
uni.showModal({
\n
title,
\n
content,
\n
showCancel: false
\n
})
\n
} else {
\n
console.log(title, content)
\n
}
\n
},
\n
async dbAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add({
\n
num: 1,
\n
tag: this.dataTag,
\n
date: new Date()
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.addId = res.id
\n
this.notify(`新增成功,id: ${res.id}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbBatchAdd() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.add([{
\n
num: 2,
\n
tag: this.dataTag,
\n
}, {
\n
num: 3,
\n
tag: this.dataTag,
\n
}])
\n
.then((res) => {
\n
uni.hideLoading()
\n
console.log(res)
\n
console.log('JSON.stringify(res.inserted)', JSON.stringify(res.inserted))
\n
this.batchAddIds = res.ids
\n
this.batchAddinserted = res.inserted
\n
this.notify(`新增成功条数${res.inserted}, id列表: ${res.ids.join(',')}`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGet() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbGetWithCommand() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where({
\n
num: db.command.gt(1),
\n
tag: this.dataTag
\n
})
\n
.field('num, tag')
\n
.orderBy('num desc')
\n
.skip(1)
\n
.limit(2)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.getWithCommandData = res.data
\n
this.notify(`获取成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbUpdate() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.update({
\n
num: 4
\n
})
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.updateUpdated = res.updated
\n
this.notify(`更新成功,更新了${res.updated}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbRemove() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('type')
\n
.where(
\n
`tag ==
\"
${this.dataTag}
\"
`
\n
)
\n
.remove()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.removeDeleted = res.deleted
\n
this.notify(`删除成功,删掉了${res.deleted}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookupInit() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
await db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
.then(() : Promise<UniCloudDBRemoveResult> => {
\n
return db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.remove()
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('local')
\n
.add([{
\n
id:
\"
local_1
\"
,
\n
name:
\"
local_1_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_1
\"\n
}, {
\n
id:
\"
local_2
\"
,
\n
name:
\"
local_2_name
\"
,
\n
tag: this.dataTag,
\n
foreign_id:
\"
foreign_2
\"\n
}])
\n
})
\n
.then(() : Promise<UniCloudDBBatchAddResult> => {
\n
return db.collection('foreign')
\n
.add([{
\n
id:
\"
foreign_1
\"
,
\n
name:
\"
foreign_1_name
\"
,
\n
tag: this.dataTag
\n
}, {
\n
id:
\"
foreign_2
\"
,
\n
name:
\"
foreign_2_name
\"
,
\n
tag: this.dataTag
\n
}])
\n
})
\n
.then((_) : void => {
\n
uni.hideLoading()
\n
this.notify('数据初始化成功', '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
console.error(err)
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbLookup() : Promise<void> {
\n
uni.showLoading({
\n
title: '加载中...'
\n
})
\n
const db = uniCloud.databaseForJQL()
\n
const local = db.collection('local')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
const foreign = db.collection('foreign')
\n
.where(`tag ==
\"
${this.dataTag}
\"
`)
\n
.getTemp()
\n
await db.collection(local, foreign)
\n
.get()
\n
.then(res => {
\n
uni.hideLoading()
\n
console.log(res)
\n
this.lookupData = res.data
\n
this.notify(`联表查询成功,取到了${res.data.length}条数据`, '提示')
\n
})
\n
.catch((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
this.notify(error.errMsg, '错误')
\n
})
\n
},
\n
async dbMultiSend() : Promise<void> {
\n
const db = uniCloud.databaseForJQL()
\n
const temp1 = db.collection('type')
\n
.where(
\n
'tag ==
\"
default-tag
\"
'
\n
).getTemp()
\n
const temp2 = db.collection('type')
\n
.where(
\n
'tag ==
\"
default-tag
\"
'
\n
).getTemp()
\n
await db.multiSend(temp1, temp2)
\n
.then<void>(res => {
\n
uni.hideLoading()
\n
let successCount = 0
\n
for (let i = 0; i < res.dataList.length; i++) {
\n
const item = res.dataList[i]
\n
if(item.errCode == 0) {
\n
console.log(`第${i}个请求查询到${item.data!.length}条数据`)
\n
successCount++
\n
} else {
\n
console.error(`第${i}个请求查询失败,错误信息:${item.data!.length}`)
\n
}
\n
}
\n
this.multiSendSuccessCount = successCount
\n
this.notify(`合并查询成功,成功查询的语句条数为:${successCount}`, '提示')
\n
})
\n
.catch<void>((err : any | null) => {
\n
uni.hideLoading()
\n
const error = err as UniCloudError
\n
console.error(err)
\n
this.notify(error.errMsg, '错误')
\n
})
\n
}
\n
}
\n
}
\n\n
```
\n
:::"
},
"onResponse"
:{
"name"
:
"## onResponse(callback) @onresponse"
,
"description"
:
"监听响应事件"
,
"compatibility"
:
"### onResponse 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.onResponse)"
},
"offResponse"
:{
"name"
:
"## offResponse(callback) @offresponse"
,
"description"
:
"移除响应事件监听"
,
"compatibility"
:
"### offResponse 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.offResponse)"
},
"onRefreshToken"
:{
"name"
:
"## onRefreshToken(callback) @onrefreshtoken"
,
"description"
:
"监听token刷新事件"
,
"compatibility"
:
"### onRefreshToken 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.onRefreshToken)"
},
"offRefreshToken"
:{
"name"
:
"## offRefreshToken(callback) @offrefreshtoken"
,
"description"
:
"移除token刷新事件监听"
,
"compatibility"
:
"### offRefreshToken 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
"### 参数
\n\n
| 名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| callback | (arg: [UniCloudResponseEvent](#unicloudresponseevent-values)) => any
\\
| null | 是 | - | - | - |
\n\n
#### UniCloudResponseEvent 的属性值 @unicloudresponseevent-values
\n\n
| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
| :- | :- | :- | :- | :-: | :- |
\n
| type | string | 是 | - | - | 响应事件类型 |
\n
| name | string | 是 | - | - | 响应事件由哪个云函数触发 |
\n
| content | any | 是 | - | - | 响应结果、错误内容 |
\n
"
,
"returnValue"
:
""
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.offRefreshToken)"
},
"getCurrentUserInfo"
:{
"name"
:
"## getCurrentUserInfo() @getcurrentuserinfo"
,
"description"
:
"获取token内缓存的用户信息"
,
"compatibility"
:
"### getCurrentUserInfo 兼容性
\n
| Web | Android | iOS |
\n
| :- | :- | :- |
\n
| 4.0 | 阿里云 3.9,腾讯云 3.91,支付宝云 3.98 | 4.11 |
\n
"
,
"param"
:
""
,
"returnValue"
:
"### 返回值
\n\n
| 类型 |
\n
| :- |
\n
| **UniCloudUserInfo** |
\n
@| 名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
\n
@| :- | :- | :- | :- | :-: | :- |
\n
@| uid | string
\\
| null | 否 | - | - | UserInfo = {<br/> / |
\n
@| role | Array
\\
<string
\\
> | 是 | - | - | ing
\\
| null;<br/> / |
\n
@| permission | Array
\\
<string
\\
> | 是 | - | - | ay
\\
<string>;<br/> / |
\n
@| tokenExpired | number | 是 | - | - | ay
\\
<string>;<br/> /** |
\n
"
,
"tutorial"
:
"
\n
### 参见
\n
- [相关 Bug](https://issues.dcloud.net.cn/?mid=api.unicloud.utils.getCurrentUserInfo)"
}}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录