sidnt
sidnt

Reputation: 300

Can a uuid be reused in Firestore?

Can a uuid be reused in Firestore and used to refer to related pieces of data, living under different collections?

In a quizzing app, let's say, in the db, there's a questions collection, whose documents are individual questions. I persist a question instance to the questions collection, and get its key x.

What if this same key x, is used to persist the answer to this question, in an answers collection in the same db? Is this possible? Could it lead to complications downstream?

The intended use case was, if the key x is applied to questions collection, we get the question, and if the same key x applied to answers collection, we get that question's answer.

Upvotes: 1

Views: 319

Answers (1)

sidnt
sidnt

Reputation: 300

Don't know if the ids generated by Firestore actually conform to the UUID specification, they are ids nevertheless.

At the time of writing this answer, it is possible to add different objects under the same Firestore generated id, in different collections belonging to the same database (though it should be possible with user generated ids as well.);

such that the same key, if redeemed against different collections, hit different objects accordingly.

Don't know if this could complicate things architecturally downstream.

Upvotes: 1

Related Questions