Skip to content

persisting a reference in a collection #1396

Discussion options

You must be logged in to vote

i wrote a vitest unit test, and after some fiddeling around it seems to work as expected (i have to rely on useDocument and their promises properly)

    it("lifecycle", async () => {
        const coll = collection(firestore, "test_entity");
        const userColl = collection(firestore, "test_user");

// setup
        const userA = await addDoc(userColl, {
            name: "User A"
        });
        const userB = await addDoc(userColl, {
            name: "User B"
        });



// create entity
        const result = await addDoc(coll, {
            name: "Foobar",
            users: [
                doc(userColl, userA.id),
         ]});
        expect(result.id).toBeTruthy()

// f…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@posva
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by digitalkaoz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants