在集合中添加一条记录。
方法定义
该方法的定义如下:
insertOne(doc: object): Promise<MongoResult>
请求参数
该方法接收 1 个参数,其定义如下:
字段名 | 类型 | 必填 | 说明 |
---|---|---|---|
doc | Object | 是 | 待插入的数据 |
示例
mpserverless.db.collection('users').insertOne({
name: 'tom',
age: 1
})
.then(res => {})
.catch(console.error)
在文档使用中是否遇到以下问题
更多建议
匿名提交