Skip to main content
Version: 2.8.y

Field Values

This page discusses how FirelordJS tackles the homogeneous FieldValue types.

Field Values

There are 5 field values in Firestore:

  1. increment
  2. serverTimestamp
  3. arrayRemove
  4. arrayUnion
  5. 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 ValueInterfaceSignatureNoteAssignable
serverTimestampServerTimestamp{ 'Firelord.FieldValue': unique symbol }Yes
incrementIncrement{ 'Firelord.FieldValue': unique symbol }auto union with numberNo
arrayRemove | arrayUnionArrayUnionOrRemove<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 ValueLabelsSignatureNoteAssignable
deleteDeleteField{ 'Firelord.FieldValue': unique symbol }allow a field to be read as undefiend and deletableYes
-PossiblyReadAsUndefined{ 'Firelord.FieldValue': unique symbol }allow a field to be read as undefiendYes