收藏
回答

云开发数据库统计匹配查询条件的记录的条数怎么获取条数数据?

js代码如下:

const countResult = db.collection('stu_uni').where({

      status: 1,

      major_classify: 1

    }).count()

    console.log(countResult)

    console.log(countResult.total)

运行结果:

想问countResult.total这个引用方式是不对吗?为什么输出undefined?

走过路过的大佬求求了康康我!是我太菜实在不知道怎么写5555

最后一次编辑于  2020-04-11
回答关注问题邀请回答
收藏

2 个回答

  • 老张
    老张
    2020-04-11

    const countResult = await db.collection('stu_uni').where().get()

    2020-04-11
    有用 1
    回复
  • qocito
    qocito
    2020-04-11

    另外还有查询得到的结果如果想使用其中的某个数值该怎么写呢?

    for (let i = 0; i < 21; i++) {

          const promise = db.collection('stu_uni').skip(i * MAX_LIMIT).limit(MAX_LIMIT).where({

            status: 1,

            major_classify: 1

          }).get()

          //console.log(promise)

          this.data.tasks.push(promise) 

          }

         console.log(this.data.tasks)

       },

    结果输出如图:

    如果想使用查询结果中的gpa属性值该怎么写呢?

    2020-04-11
    有用
    回复 1
    • qocito
      qocito
      2020-04-11
      console.log(this.data.tasks[0].data[0].gpa) 如果写成这样就会报错?
      2020-04-11
      回复
登录 后发表内容
问题标签