Vuexfire duplicated objects returned when using collection.
See original GitHub issueI 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:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.In case someone else lands here I had called ‘…vuexfireMutations’ from multiple places. Resolving that fixed the duplicates for me.