提交 2a1d5541 编写于 作者: 雪洛's avatar 雪洛

Update cf-database.md

上级 8804e484
......@@ -237,12 +237,30 @@ exports.main = async (event, context) => {
方法1: collection.add(data)
示例:
参数说明
| 参数 | 类型 | 必填 | 说明 |
| ---- | ------ | ---- | ---------------------------------------- |
| data | object | array | 是 | {_id: '10001', 'name': 'Ben'} _id 非必填|
响应参数
单条插入时
| 参数| 类型 | 说明 |
| ----| ------| ---------------------------------------- |
|id | String|插入记录的id |
批量插入时
| 参数 | 类型 | 说明 |
| ---- | ------| ---------------------------------------- |
| inserted| Number| 插入成功条数 |
|ids | Array |批量插入所有记录的id |
示例:
```js
// 单条插入数据
let res = await collection.add({
......@@ -256,13 +274,8 @@ let res = await collection.add([{
},{
name: 'John'
}])
// res.inserted // 插入成功条数
// res.ids // 批量插入返回的所有记录 id
// res.result // 阿里云特有,批量插入返回的所有记录 id,推荐使用ids
```
<!-- // res.failIndexes // 腾讯云特有,插入失败的记录的下标 -->
**Tips**
- 云服务商为阿里云时,若集合不存在,调用add方法会自动创建集合
......@@ -349,8 +362,6 @@ let res = await db.collection('goods').where({
| 字段 | 类型 | 必填 | 说明 |
| --------- | ------- | ---- | ------------------------ |
| code | string | 否 | 状态码,操作成功则不返回 |
| message | string | 否 | 错误描述 |
| total | Integer | 否 | 计数结果 |
| requestId | string | 否 | 请求序列号,用于错误排查 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册