I have the following collection in my Firestore database:
Which I can bind to my vuex store with the following:
state: {
assets: [],
},
actions: {
bindAssets: firestoreAction(({ bindFirestoreRef }) => {
return bindFirestoreRef('assets', db.collection('assets'))
}),
},
However this binds them to assets
as a list, I.e.
[
{id: "id1" /* etc. */ },
{id: "id2" /* etc. */ },
{id: "id3" /* etc. */ },
]
Where as, I'd like it to be bound as:
{
"id1": { /* etc. */ },
"id2": { /* etc. */ },
"id3": { /* etc. */ },
}
How can I achieve this?
If you want to transform the
assets
array (obtained by binding theassets
collection) in an Object as shown belowthe following Vuex getter should do the trick:
Update following your comments (in the chat):
If you want to bind to only one document, you should do as follows, with
bindAssetDoc
andassetDoc
.STORE
COMPONENT opened through
/asset/:assetId