查询语句,返回的是 res.data[] 数组
调用云函数返回的是res.result
get 数据获取返回的是 res.data{} 对象
this.DB = wx.cloud.database()
wx.cloud.init({
env: 'mm-4t7rg'
})
wx.cloud.callFunction({
name: "login",
data: {},
success(res) {
console.log('个人信息-------------',res.result.openid)
},fail(err){
console.log('个人信息-------------',err)
}
})
复制代码
DB.collection('user').where({openId: openId})
.get().then(ress => {
console.log('res',ress.data[0])
})
复制代码
const db = wx.cloud.database()
db.collection(user).where({
name: {
$regex: '.*' + this.data.inputVal + '.*',
$options: '1'
}
}).get().then(res=>{
console.log(res.data[0])
})
复制代码
getApp().DB.collection('user').add({
data: {id:"123"},
success: function (res) {
console.log('--------', res.data)
}
})
复制代码
getApp().DB.collection('friends').where(_.or([
{a: wx.getStorageSync('mch_id')+''},
{b: wx.getStorageSync('USER_INFO').id}]))
.get().then(res => {
console.log('我的好友',res.data)
})
复制代码
getApp().DB.collection('user').doc('云数据库存的_id').get().then(res=>{
console.log('========',res.data.name)
})
复制代码
DB.collection('invitation_list').doc(this.data.id).update({
data: {
status: 2
},
success: function (res) {
}
})
复制代码
this.DB.collection('groupList').where({'kid':kid}).update({data:groupData}).then(res=>{
console.log('automatic_group_upData-更新成功',res)
rrr(true)
})
复制代码
const db = wx.cloud.database()
const _ = db.command;
db.collection('groupList').where({
userList: _.elemMatch({
openid: this.user.info.openid,
})
})
.watch({
onChange: function(snapshot) {
console.log('snapshot', snapshot)
},
onError: function(err) {
console.error('the watch closed because of error', err)
}
})
复制代码
upLoad() {
wx.chooseImage({
success: chooseResult => {
console.log('chooseResult.tempFilePaths[0]', chooseResult.tempFilePaths[0])
wx.cloud.uploadFile({
cloudPath: '11aachatImg/' + new Date().getTime(),
filePath: chooseResult.tempFilePaths[0],
success: res => {
console.log('上传成功', res)
let imgUrl = res.fileID
},
fail: err => {
console.log('失败', err)
}
})
},
})
},
复制代码
app.DB.collection('groupList')
.where({
groupType: groupType,
userList: _.elemMatch({
openid: this.data.my.openid,
})
}).get()
.then(res => {
console.log('getGroupList-res', res.data)
})
复制代码
let limit=20;
let skip=0;
onLoad(){
app.DB.collection('groupList')
.where({
groupType: groupType,
userList: _.elemMatch({
openid: this.data.my.openid,
})
})
.skip(skip)
.limit(limit)
.get()
.then(res => {
console.log('getGroupList-res', res)
if (groupType == 1) {
that.setData({
list_1: [...that.data.list_1, ...res.data], //合并数据
list_2: false,
isEndOfList: res.data.length < limit ? true : false //判断是否结束
})
} else {
that.setData({
list_1: false,
list_2: [...that.data.list_2, ...res.data], //合并数据
isEndOfList: res.data.length < limit ? true : false //判断是否结束
})
}
})
},
onReachBottom: function () {
!that.data.isEndOfList && that.getData()
},
复制代码
let info_id = that.data.info._id
console.log('this.data.my.openid',this.data.my.openid)
DB.collection('groupList')
.where({
_id: info_id,
"userList.openid": this.data.my.openid
}).update({
data: {
"userList.$.status":true,
}
}).then(res=>{
console.log(res)
})
复制代码
DB.collection('friends').where(
_.or([{
a_openid: mopenid,
b_openid: uopenid
}, {
a_openid: uopenid,
b_openid: mopenid
}])
)
.get().then(ress => {
console.log('res', ress.data)
if (ress.data.length > 0) {
console.log('clickHead-已经是好友', JSON.stringify(ress.data))
} else {
DB.collection('friends').add({
data: chatData
}).then(res => {
console.log('clickHead-创建好友关系成功', res)
})
}
})
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。