Comments (13)
Hi,
I found a bug in openDBChannel that I fixed in the latest version.
Can you do npm i vuex-easy-firestore@latest
and confirm for me?
instead of this:
dispatch('users/openDBChannel', {where: [['uid', '==', 'XYZ']]}))
please try this again:
yourModule = {
sync: {
where: [
['uid', '==', '{uid}']
]
}
}
// and just do this:
dispatch('users/openDBChannel', { uid: 'XYZ' })
I found a bug that prevented that bottom one from working, but should now be fixed.
Please try it for me and confirm you get this:
createEasyFirestore({
firestorePath: 'users/',
firestoreRefType: 'collection',
moduleName: 'users',
sync: {
where: [
['uid', '==', '{uid}']
]
}
})
// Run
dispatch('users/openDBChannel', { uid: 'ABC' })
state : { // Result after dispatch('users/openDBChannel', { uid: 'ABC' })
users: {
'ABC' : data
}
}
dispatch('users/openDBChannel', { uid: 'XYZ' })
state : { // Result after dispatch('users/openDBChannel', { uid: 'ABC' })
users: {
'ABC' : data
'XYZ' : data // XYZ is added instead of overwriting
}
}
from vuex-easy-firestore.
I'm very confused by your setup.
Is there a reason you need to use firestoreRefType: 'doc'
as opposed to collection
?
If you just save it like so:
createEasyFirestore({
firestorePath: 'users/',
firestoreRefType: 'collection',
moduleName: 'users',
})
you already have all the setup you need. And users will be added automatically just like you want it to.
from vuex-easy-firestore.
@mesqueeb Tried with collection
but how to get multiple like that? Its just replaced their old own object
from vuex-easy-firestore.
The example I gave above. It will save all users like you want:
state : {
users: {
'ABC' : userData,
'XYZ' : userData,
}
}
from vuex-easy-firestore.
@mesqueeb Thanks, im not sure why I got..
createEasyFirestore({
firestorePath: 'users/',
firestoreRefType: 'collection',
moduleName: 'users',
sync: {
where: [
['uid', '==', '{uid}']
]
}
})
// Run
dispatch('users/openDBChannel', { uid: 'ABC' })
state : { // Result after dispatch('users/openDBChannel', { uid: 'ABC' })
users: {
'ABC' : 'data'
// _conf: (...)
// _sync: (...)
}
}
dispatch('users/openDBChannel', { uid: 'XYZ' })
state : { // Result after dispatch('users/openDBChannel', { uid: 'ABC' })
users: {
'XYZ' : 'data'
// _conf: (...)
// _sync: (...)
}
}
That 'ABC' : 'data'
from prev is gone
Note: I'm using where
because I don't want to get the whole users
from vuex-easy-firestore.
@l2aelba I understand what's happening now. The other user document is being removed.
- a 'collection' is usually for multiple documents grouped in a single vuex module
- a 'doc' for a single doc also saved in a single vuex module
In your case I want to understand:
- How many ID's you need to filter on?
- Why do you need to filter on those IDs?
This is important to understand if you could maybe set up your firestore DB design differently.
Based on this information I think I can help you better.
from vuex-easy-firestore.
@mesqueeb
Filter ? This we will get the whole users from DB and filter it by client-side?
Are you talking about sync.fillables
or where
?
from vuex-easy-firestore.
No not fillables, I'm talking about where
I mean: you want to only get user's { uid: 'ABC' }
and { uid: 'XYZ' }
.
Is it always those two? Is it more? Is there a reason you need to filter on specific UID's?
from vuex-easy-firestore.
@mesqueeb Gotcha! You are right!
I got with..
dispatch('users/openDBChannel', { where: [ ['uid', '==', uid] ] })
I did wrong with where
in the wrong place like
// dispatch('users/openDBChannel')
sync: {
where: [
['uid', '==', '{uid}']
]
}
Thanks so much!
from vuex-easy-firestore.
@l2aelba Yes, today I have rewrote the library so it's possible to pass new where
filters on each openDBChannel
.
But, I still want to know why you need to do this.
There's a possibility in your case it's better to use fetchAndAdd
instead of openDBChannel
. But I don't understand what your app is, or why you want to filter on single ID's.
It's also usually better to just add an extra field to the users you want to retrieve to filter on.
Eg. if you add a field like thisIsTheOne: true
to all users you need (eg. 'ABC' and 'XYZ') then you can just do
dispatch('openDBChannel', {where: [['thisIsTheOne', '==', true]]})
Why do you need to filter each time on a specific ID?
from vuex-easy-firestore.
@mesqueeb I making a chat app
I don't want user to watch all changes from all users (Firebase Reading is cost money)
I just want that user to watch changes just their friends :)
So this is just about performance and money
from vuex-easy-firestore.
@mesqueeb Confirmed! It's work now! and thank for this 👍
from vuex-easy-firestore.
After about two years of open source, I finally got accepted for Github Sponsors!
💜 github.com/sponsors/mesqueeb 💜
A little about me:
- I love open-source
- 6 months ago I got a son, and am trying to be an awesome father 😅
- I'm doing freelance work here and there as my main job
If anyone was helped with vuex-easy-firestore, I'd greatly appreciate any support!
BTW, donations get's paid DOUBLE by GitHub! (they're alchemists... 🦾)
Going forward 👨🏼💻
- I got great plans for the future of vuex-easy-firestore going above and beyond!! Look forward to it!!
- On to many more years of open-sourcing! 🎉
from vuex-easy-firestore.
Related Issues (20)
- cannot read resolve of undefined HOT 7
- Feature: Add firestore.getAll() on the web HOT 7
- Question: can we rely on the `signedIn` getter to check if the user is signed in? HOT 3
- Guard 'id' will still add 'id' on update HOT 1
- Reacting to changes in vue-router HOT 1
- Retrieve subcollections together with document HOT 2
- feat(docs): add firestore guide
- RangeError: Maximum call stack size exceeded HOT 6
- ProjectId not provided in firebase.initializeApp despite being provided HOT 3
- Can't get it to work no matter what! HOT 6
- Two-way binding HOT 4
- Getters undefined when working with users collection + sign in onAuthStateChanged [Help]
- fetch only returns id in doc HOT 2
- Update library for firebase v9 HOT 3
- Adding "in" or "array-contains" to the where clause
- setPathVars should be better documented HOT 1
- Doc insertion from multiple apps at he same index
- project build process HOT 1
- E2E test with Cypress
- syncStack / rejects HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vuex-easy-firestore.