Emulating Unique Constraints in Google Firestore

2 · Adrian Ancona Novelo · Dec. 16, 2020, 11:27 a.m.
Compared to most popular databases, Google Firestore is very minimalistic. A very important feature that it lacks, is that of unique constraints (unique indexes). This feature is particularly important when we are building a system that allows users to pick a username. If we don’t enforce uniqueness we could end with two users with the same username, which is not what we want. Using Document ID and transactions If we are able to use the username as the user id, then things are a little easier. W...