0

I am trying to make an 'in' query like this: db.collection('units').where('SuperID', 'in', payload)

SuperID: is a number

payload: is an array of numbers matching the SuperIDs

I am doing this so I can group users based off a document like this

enter image description here

Vuex Store

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

Method

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

  ggs(payload){

      console.log(payload)

      this.getgs(payload)
  }
}

It console logs payload but then says its undefined

Whenever I try to call it, it logs the array that I need but then says that its undefined and throws the Firebase error.

Yewla
  • 325
  • 3
  • 21

1 Answers1

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.

Austin Fay
  • 500
  • 3
  • 16