指定查询结果集数量上限
方法签名如下:
function limit(max: number): Collection | Query
方法接受一个必填参数 max 用于定义最大结果集返回数量,上限 100
示例代码
const cloud = require('wx-server-sdk')
cloud.init()
const db = cloud.database()
exports.main = async (event, context) => {
  try {
    return await db.collection('todos').limit(10).get()
  } catch(e) {
    console.error(e)
  }
}(c) 2024 chaojicainiao.com MIT license