-
-
Notifications
You must be signed in to change notification settings - Fork 345
Use withConverter together with bindFirestoreRef for firestoreAction #608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
Comments
Closed
I've been able to use import * as schema from '@vendida/schema';
import { Action, Module, VuexModule } from 'vuex-module-decorators';
import firebaseApp from '../../utils/firebase';
import { firestoreAction } from 'vuexfire';
@Module({ name: 'Categories' })
export default class Categories extends VuexModule {
categories: schema.models.Category[] = [];
@Action
bindCategories() {
return (firestoreAction(
({ bindFirestoreRef }) =>
bindFirestoreRef(
schema.models.Category.COLLECTION_NAME,
firebaseApp
.firestore()
.collection(schema.models.Category.COLLECTION_NAME)
.withConverter(schema.models.Category.getFirestoreConverter())
)
) as Function)(this.context);
}
@Action
unbindCategories() {
return (firestoreAction(
({ unbindFirestoreRef }) =>
unbindFirestoreRef(schema.models.Category.COLLECTION_NAME)
) as Function)(this.context);
}
} |
This is the second time I've arrived here looking for this answer, so for future Chris, here you go, past Chris got it working.
|
posva
added a commit
that referenced
this issue
Oct 19, 2022
Close #608 BREAKING CHANGE: `options.serialize()` is replaced with `converter`. It effectively has the same effect as calling `doc().withConverter()` or `collection().withConverter()` but it allows to have a global converter that is automatically applied to all snapshots. This custom converter adds a non-enumerable `id` property for documents like the previous `serialize` options. **If you were not using this option**, you don't need to change anything.
Implemented in 18224e4 (might still change and feedback welcome once it's released) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to use
withConverter
to convert streaming data from Firestore directly within afirestoreAction
action so that objects can be transformed/converted to custom types?I tried it but the issue is that
bindFirestoreRef(..)
requires afirestore.CollectionReference<firestore.DocumentData> | firestore.Query<firestore.DocumentData>
as second parameter (the query/Firestore reference). So you cannot just append.withConverter(...)
to the query that is handed to thebindFirestoreRef(...)
.Is this possible somehow?
The text was updated successfully, but these errors were encountered: