小程式雲開發獲取不到資料庫的記錄

Bright2017發表於2018-10-25

問題描述
嘗試小程式使用雲資料庫獲取記錄,進行除錯的時候,控制檯結果一直返回這個,如圖:

控制檯列印為空

wx.cloud.init();
const db = wx.cloud.database()

Page({
  data: {
   
  },
  //載入資料
  onLoad:function(){
   // collection 方法獲取一個集合的引用
    db.collection('items').where({
    }).get({ // get 方法會觸發網路請求,往資料庫取資料
      success: function (res) {
        console.log(res)
      }
    })
  },
})

解決方案:

資料庫新建的collectioin需要設定許可權,沒有問題就可以讀取和更新了

轉載地址:https://blog.csdn.net/qq_31975963/article/details/82855327

相關文章