set
The method allows setting a document by its id. It’s available on Collection
, Ref
, and Doc
.
The method returns Ref
instance:
Typesaurus expects you to pass complete data. If the document already exists, it will be overwritten.
It accepts a function as the argument that allows you to use the $
helper object:
$
helper
The argument function receives the $
helper object as the first argument that provides write helpers.
$
type is TypesaurusCore.WriteHelpers
.
$.serverDate
To assign a server date to a field, use $.serverDate
:
It will assign the date when Firestore saves the document.
→ Read more about server dates.
Options
as
You can tell Typesaurus that it’s safe to set dates to server dates by passing the as
option ("server" | "client"
):
By default, Typesaurus uses the "client"
option.