wxml:

<button type="primary" bindtap="getBuyerBasicsRecordNumber">获取记录个数</button>

wxss:

page{
  padding: 10rpx;
  box-sizing: border-box;
}

input{
  border: 1px solid #000;
}

js(写法一):

// 连接微信云数据库
const db = wx.cloud.database()

Page({
  data: {

  },

  // 获取buyerBasics的记录的个数
  getBuyerBasicsRecordNumber(){
    db.collection("buyerBasics")
    .get()
    .then(res=>{
      console.log(res)
    })
  },

  onLoad: function (options) {

  }
})

js(写法二):

// 连接微信云数据库
const db = wx.cloud.database()

Page({
  data: {

  },

  getBuyerBasicsRecordNumber(){
    db.collection("buyerBasics")
    .count()
    .then(res=>{
      console.log(res)
    })
  },

  onLoad: function (options) {

  }
})

前端效果图:

在这里插入图片描述

后端运行结果:
js(写法一):
在这里插入图片描述
js(写法二):
在这里插入图片描述

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐