Closed andersbc closed 4 years ago
@andersbc with doc mode you need the id in your firestorePath
.
Eg. firestorePath: 'users/{userId}',
btw, {userId}
is a special path variable that automatically uses Firebase Auth userId of the authenticated user.
If you want to open the module for other users as well you need to do:
firestorePath: 'users/{id}'
and
this.$store.dispatch('user/openDBChannel', {pathVariables: {id: 'some-user-id'}})
More info on this feature here: https://mesqueeb.github.io/vuex-easy-firestore/extra-features.html#variables-for-firestorepath-or-clauses
--
Vuex Easy Firestore was made with ♥ by Luca Ban.
If you use this library in your projects, you can support the maintenance of this library by a small contribution via Github 💜.
You can also reach out on twitter if you want a one-on-one coding review/lesson. 🦜
Thanx, @mesqueeb :-)
I went with using a collection, as you suggest in the link you provided.. to save a round trip to firestore. I already had a users collection set up.
You probably know this, but in case other reads this, you can query a firestore collection for a single doc, by it's id ...with this trick:
this.$store.dispatch('users/openDBChannel', {
where: [['__name__', '==', props.clientId]],
})
apparently '__name__'
works as a placeholder for the doc id in a firebase query (https://stackoverflow.com/questions/47876754/query-firestore-database-for-document-id)
So, in my component I first check if my particular user is included in my already fetched users collection (getById
getter), and if not I issue the openDBChannel
command above to populate the collection with the single user I need for that particular component.
Sorry to bother you with this simple question, I have looked but just can't find it in the docs.. :-(
I want to open a realtime listener for a specific doc ..but i can't figure out where to put the id of the doc:
This is my setup:
Any help appreciated, thanx :-)