Skip to content

Commit

Permalink
Update cf-database.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Wangyaqi committed Jun 17, 2020
1 parent 8804e48 commit 2a1d554
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions docs/uniCloud/cf-database.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,30 @@ exports.main = async (event, context) => {

方法1collection.add(data)

示例:
参数说明

| 参数 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| data | object | array || {_id: '10001', 'name': 'Ben'} _id 非必填|

响应参数

单条插入时


| 参数| 类型 | 说明 |
| ----| ------| ---------------------------------------- |
|id | String|插入记录的id |

批量插入时

| 参数 | 类型 | 说明 |
| ---- | ------| ---------------------------------------- |
| inserted| Number| 插入成功条数 |
|ids | Array |批量插入所有记录的id |

示例:

```js
// 单条插入数据
let res = await collection.add({
Expand All @@ -256,13 +274,8 @@ let res = await collection.add([{
},{
name: 'John'
}])
// res.inserted // 插入成功条数
// res.ids // 批量插入返回的所有记录 id
// res.result // 阿里云特有,批量插入返回的所有记录 id,推荐使用ids
```

<!-- // res.failIndexes // 腾讯云特有,插入失败的记录的下标 -->

**Tips**

- 云服务商为阿里云时,若集合不存在,调用add方法会自动创建集合
Expand Down Expand Up @@ -349,8 +362,6 @@ let res = await db.collection('goods').where({

| 字段 | 类型 | 必填 | 说明 |
| --------- | ------- | ---- | ------------------------ |
| code | string || 状态码,操作成功则不返回 |
| message | string || 错误描述 |
| total | Integer || 计数结果 |
| requestId | string || 请求序列号,用于错误排查 |

Expand Down

0 comments on commit 2a1d554

Please sign in to comment.