api接口 collection.field 中db.command.project.slice报错
发布于 7 年前 作者 junshi 15056 次浏览 来自 官方Issues

文档api云开发collection.field中

const db = wx.cloud.database()db.collection('todos').field({

 description: true,  done: true,  progress: true,  // 只返回 tags 数组前 3 个元素  tags: db.command.project.slice(3),})  .get()  .then(console.log)

 .catch(console.error)

如果指定的字段是数组字段,还可以用以下方法只返回数组的第一个元素:在该字段 key 后面拼接上 .$ 成为 字段.$ 的形式。                                

而且如果指定的字段是数组字段,还可以用 db.command.project.slice 方法返回数组的子数组:

tags: db.command.project.slice(3)这个方法报错, .$方法也不能用

VM5295:1 Error: errCode: -501007 invalid parameters | errMsg: [InvalidParameterValue.QueryProjection] Query projection entered in the request is illegal. Please check your request, but if the problem persists, contact us.

代码:

            

db.collection('teaUsers').field({

// 只返回 tags 数组前 3 个元素

haha: db.command.project.slice(1),

})

.get()

.then(console.log)

.catch(console.error)

},

云数据:


回到顶部