0

我正在尝试进行这样的 'in' 查询: db.collection('units').where('SuperID', 'in', payload)

SuperID:是一个数字

有效载荷:是与 SuperID 匹配的数字数组

我这样做是为了可以根据这样的文档对用户进行分组

在此处输入图像描述

Vuex 商店

getgs: firestoreAction(({ bindFirestoreRef, payload }) => {
      //return the promise returned by 'bindFirestoreRef'
      return bindFirestoreRef('gs', db.collection('units').where('SuperID', 'in', payload))
    }), 

方法

methods: {
    ...mapActions(['getgs']),

  ggs(payload){

      console.log(payload)

      this.getgs(payload)
  }
}

它控制台记录有效负载,然后说它未定义

每当我尝试调用它时,它都会记录我需要的数组,然后说它未定义并引发 Firebase 错误。

4

1 回答 1

1

Ok I think I found the answer this time.

Using this example from the docs:

actions: {
  checkout ({ commit, state }, products) {
    // save the items currently in the cart
    const savedCartItems = [...state.cart.added]
    // send out checkout request, and optimistically
    // clear the cart
    commit(types.CHECKOUT_REQUEST)
    // the shop API accepts a success callback and a failure callback
    shop.buyProducts(
      products,
      // handle success
      () => commit(types.CHECKOUT_SUCCESS),
      // handle failure
      () => commit(types.CHECKOUT_FAILURE, savedCartItems)
    )
  }
}

It looks like your action definition should be

getgs: firestoreAction(({ bindFirestoreRef }, payload) => {
      //return the promise returned by 'bindFirestoreRef'
      return bindFirestoreRef('gs', db.collection('units').where('SuperID', 'in', payload))
    }), 

With the payload outside of the context object.

于 2020-06-22T15:07:18.853 回答