在集合中添加一批记录。
方法定义
insertMany(docs: object[]): Promise<MongoResult>
请求参数
字段名 | 类型 | 必填 | 说明 |
---|---|---|---|
docs | Array | 是 | 待插入的数据,只能为对象数组,数组中的每个元素作为一个数据条目。docs 字段不能为空数组 [] 。 |
示例
向users集合中插入两条记录。
mpserverless.db.collection('users').insertMany([{
name: 'tom',
age: 1
}, {
name: 'jerry',
age: 2
}])
.then(res => {})
.catch(console.error)
在文档使用中是否遇到以下问题
更多建议
匿名提交