微信小程序雲開發 數據庫查詢腳本語法

// 雲函數入口文件
const cloud = require('wx-server-sdk')

cloud.init()

const db = cloud.database()
const dbList = db.collection('playlist')

// 雲函數入口函數
exports.main = async(event, context) => {
  //skip 表示從哪裏開始取
  // limit 表示要取的數量
  // orderBy 表示排序 (排序的字段,排序的方式)
  // where 查詢條件
  return await dbList.skip(event.start).limit(event.count).orderBy('creatTime', 'desc').get().then(res => {
    return res
  })
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章