1. 程式人生 > >微信小程式學習筆記(四)

微信小程式學習筆記(四)

雲函式條件查詢

exports.main = async (event, context) => { try { return await db.collection('sweething').where({ id: event.id }) .get({ success(res) { // res.data 是一個包含集合中有許可權訪問的所有記錄的資料,不超過 20 條 console.log(res.data) } }) } catch (e) { console.error(e) } }   id: event.id通過id去查詢始終沒有查詢結果,最後定位原因是event.id 是number型別而資料庫中的id是string型別 之所以剛開始沒有發現number和string型別的區別是因為小程式的json資料庫中number和string型別是一樣的寫法都不加“”或者‘’,以為沒有區別;