Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

When using withConverter on collection it do not fetch inner refs #1491

Closed
Pawelrutka-bb opened this issue Feb 12, 2024 · 0 comments
Closed

Comments

@Pawelrutka-bb
Copy link

Reproduction

When using withConverter on collection it do not fetch inner refs

Steps to reproduce the bug

I have custom type

class CalendarModel {
    owner: DocumentReference // firestore ref
    min_book_time_min: number
    book_time_interval_min: number

    constructor(owner: DocumentReference, min_book_time_min: number, book_time_interval_min: number) {
        this.owner = owner
        this.min_book_time_min = min_book_time_min
        this.book_time_interval_min = book_time_interval_min
    }
}

and converter

const calendarModelConverter = {
    toFirestore(cal: CalendarModel): firebase.firestore.DocumentData {
        return { min_book_time_min: cal.min_book_time_min, book_time_interval_min: cal.book_time_interval_min };
    },
    fromFirestore(
        snapshot: firebase.firestore.QueryDocumentSnapshot,
        options: firebase.firestore.SnapshotOptions
    ): CalendarModel {
        const data = snapshot.data(options)!;
        return new CalendarModel(data.owner, data.min_book_time_min, data.book_time_interval_min);
    }
};

and I do

useCollection(collection(db, `facilities/${facility}/calendars`).withConverter<CalendarModel, DocumentData>(calendarModelConverter))

This yields that owner is not getting fetched automatically. Is there a bug or VuewFire API miss use ? If i skip withConverter, data is fetched.

Expected behavior

Refs are populated

Actual behavior

Refs are not populated

Additional information

No response

@vuejs vuejs locked and limited conversation to collaborators Feb 13, 2024
@posva posva converted this issue into discussion #1492 Feb 13, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant