Vuefire 数据未订阅更改

问题描述

我有几个不同的查询需要保留“实时”数据。当我对查询进行硬编码时,它成功地显示数据库中发生的所有实时更改。但是当我传递有效负载时,数据在重新加载之前不会改变。

工作查询

getonline: firestoreAction(({ bindFirestoreRef }) => {
      
      return bindFirestoreRef('online',db.collection('units').where('unit.on','==',true).orderBy('info.timestamp','desc').orderBy('unit.status'))

    }),

无效载荷查询获取次数

getFilterSystemId: firestoreAction(({ bindFirestoreRef},payload) => {
      
      return bindFirestoreRef('filterBySystemId',db.collection('units').where('unit.group',payload.group).orderBy('info.timestamp',

我只是简单地传递有效载荷:

filterSystemId(grouphex){

    let payload  = {
      group: grouphex.toString(),}

    this.getFilterSystemId(payload);

  },

如何传递负载并实时更新数据库中发生的任何更改?

解决方法

最终使用 vuefire 而不是 vuexfire 并像这样动态绑定我的查询。

const vuefire = db.collection('vuefire')

export default {
  components: {},data() {
    return {
    //view
    vuefire: [],id: 'true',user: [],code: 'true'
     
    };
  },created() {
  },// firestore: {
  //   vuefire: db.collection('vuefire')
  // }

  watch: {
    id: {
      // call it upon creation too
      immediate: true,handler(id) {
        this.$bind('user',vuefire.where('a','==',id))
      },},

任何时候“id”更改数据集(“user”)都会重新计算并实现我的目标