Field Values
This page discusses how FirelordJS tackles the homogeneous FieldValue
types.
Field Values
There are 5 field values in Firestore:
- increment
- serverTimestamp
- arrayRemove
- arrayUnion
- deleteField
And they all sharing the same type: FieldValue
, which means is it possible to assign any field value to any field value, this is a point of failure.
FirelordJS solves this by assigning unique symbol type:
Field Value | Interface | Signature | Note | Assignable |
---|---|---|---|---|
serverTimestamp | ServerTimestamp | { 'Firelord.FieldValue': unique symbol } | Yes | |
increment | Increment | { 'Firelord.FieldValue': unique symbol } | auto union with number | No |
arrayRemove | arrayUnion | ArrayUnionOrRemove<T> | { 'Firelord.FieldValue': unique symbol, 'Firelord.ArrayFieldValue': T } | auto union with T[] | No |
UnassignAble Field Values
ArrayUnionOrRemove<T>
and Increment
are not assignable types and are not exported, they are passive types that automatically union with other types.
Utility Types
Labels are FirelordJS special interfaces, you can use them to "mark" you field and they will carry out special type transformation or allow you to perform certain action onto your field.
Field Value | Labels | Signature | Note | Assignable |
---|---|---|---|---|
delete | DeleteField | { 'Firelord.FieldValue': unique symbol } | allow a field to be read as undefiend and deletable | Yes |
- | PossiblyReadAsUndefined | { 'Firelord.FieldValue': unique symbol } | allow a field to be read as undefiend | Yes |