本想在云数据库中取出数组,但是取不出啊 啊 啊 啊啊
请大佬赐教!!!!
var oopp = wx.cloud.database().collection("reservation").get();
console.log("请求oopp", oopp)
var goods_arr = [];
// oopp.forEach(res => {
oopp.then(res => {
var ooop1=res.data
console.log("resoopp请求",res.data)
var goods = new Object();
goods.productId = res.data[0].productId;
goods.productQuantity = res.data[0].productQuantity;
console.log("resoopp请求id", res.data[0].productId)
goods_arr.push(goods)
console.log("请求goodsp", goods)
console.log("请求goods_arr", goods_arr)
console.log("请求JSONgoods_arr", JSON.stringify(goods_arr))
// var goods_josn = JSON.stringify(goods_arr);
//console.log("uop请求1", goods_josn)
});
var goods_josn = JSON.stringify(goods_arr);
console.log("uop请求",goods_josn)
console.log("uop请求JSON:", JSON.stringify(goods_arr))
promise不是这么用的吧,,你还是结合文档来、
https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/collection/Collection.get.html
用watch一次取完,还可以监视
const db = wx.cloud.database()
const watcher = db.collection('reservation').where({}).watch({
onChange: function(snapshot) {
console.log('snapshot', snapshot)
},
onError: function(err) {
console.error('the watch closed because of error', err)
}
})