Set
This page discusses how set works and its quirks.
We will use setDoc
in the example, but it works the same for batch.set
and transaction.set
.
Stop Unknown Member
Like update, FirelordJS stop unknown member from entering Firestore.
see update for more explanation about this behavior.
Merge Fields
Merge fields Set behave like merge, except that it updates only the listed member and ignore the rest.
Dot Notation Path
You cannot use dot notation for data, both Firestore and FirelordJS will stop you from you doing so.
Dot Notation will be treated as unknown member.
Unlike update, set treats b.c
as field b.c
not field c
of b
.
If the code runs, this is what you will see in the database:
{
a: 1,
'b.c': 1,
}
This is NOT what you will get:
{
a: 1,
b: { c: 1 },
}
The question is, should FirelordJS alters the behavior of set, so it tallies with the characteristic of update(uniformity)?
FirelordJS tries not to alters the behavior if possible. The reason FirelordJS alters update is out of necessity due to update dangerous implicit data deletion behavior.
But there is no dangerous implicit effect in set operations, so FirestoreJS keep thing as it is now.
Will give this deeper thoughts in future as uniform API improve developer experience.