question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vuexfire duplicated objects returned when using collection.

See original GitHub issue

I am trying to bind a collection with a where query. However, each time I bind the collection it returns an array with duplicated results as following:

[{Object 1 relating to doc 1},
{Object 2 relating to doc 2},
{Object 2 relating to doc 2},
{Object 1 relating to doc 1}]

The code I am using is the following:

// In my vuex store
const actions = {
  setEnquiriesRef: firebaseAction((context, ref) => {
    context.bindFirebaseRef('enquiries', ref).then((val) => {
      console.log('enquiries bound', val) // This val gives the output above, and is the same as the bound value
    })
  })
}

// In my vue component where I call the function:
let ref = firestore.collection('enquiries').where('uid', '==', 'Relevant uid')
this.$store.dispatch('setEnquiriesRef', ref)

Some notes:

  • If the ref is a document it works as expected.
  • If the ref is a collection without the where query the same duplication happens.
  • This is using "vuexfire": "^3.0.0-alpha.14"
  • If i simply run a one-time get on that reference it returns the correct data as expected (Not duplicated).
  • It always loads the documents in a particular order (Either default or with orderBy), and the duplicates are always the reverse of this.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
cairincommented, Mar 5, 2019

Update: I wasn’t understanding how the firebaseMutations were being registered, so I was adding them to each of my modules in my store. Which is obviously unnecessary and was causing the duplicate.

1reaction
bradintheusacommented, May 3, 2020

In case someone else lands here I had called ‘…vuexfireMutations’ from multiple places. Resolving that fixed the duplicates for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vuexfire get values from nested object in an array
I use vuexFire, firebase and vue. Thanks a lot. import { ... } from 'quasar'; export default { data() { return { };...
Read more >
Vuexfire bind Firestore collection to Object instead of a List ...
Coding example for the question Vuexfire bind Firestore collection to Object instead of a List-Vue.js.
Read more >
Vuexfire guide: simplify your Vue.js application state ...
The problem tackled by VuexFire is pretty simple: keeping you state data in sync with the data in Firebase Firestore or RTDB.
Read more >
6 Hour Vue.js & Firebase Project - FireBlogs - YouTube
Build a multi-user blog project with Vue.js, ...
Read more >
Vuex duplicating objects instead of updating them - Vue Forum
I'm getting data from cloud-firestore and use it in some tiles. ... then I get a duplicate vuex object (and because of this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found