WriteBatch
public extension WriteBatch-
Encodes an instance of
Encodableand overwrites the encoded data to the document referred bydoc. If no document exists, it is created. If a document already exists, it is overwritten.See
Firestore.Encoderfor more details about the encoding process.Declaration
Swift
@discardableResult func setData<T: Encodable>(from value: T, forDocument doc: DocumentReference, encoder: Firestore.Encoder = Firestore .Encoder()) throws -> WriteBatchParameters
valueAn instance of
Encodableto be encoded to a document.encoderThe encoder instance to use to run the encoding.
docThe document to create/overwrite the encoded data to.
Return Value
This instance of
WriteBatch. Used for chaining method calls. -
Encodes an instance of
Encodableand overwrites the encoded data to the document referred bydoc. If no document exists, it is created. If a document already exists, it is overwritten. If you pass merge:true, the providedEncodablewill be merged into any existing document.See
Firestore.Encoderfor more details about the encoding process.Declaration
Swift
@discardableResult func setData<T: Encodable>(from value: T, forDocument doc: DocumentReference, merge: Bool, encoder: Firestore.Encoder = Firestore .Encoder()) throws -> WriteBatchParameters
valueAn instance of
Encodableto be encoded to a document.docThe document to create/overwrite the encoded data to.
mergeWhether to merge the provided
Encodableinto any existing document.encoderThe encoder instance to use to run the encoding.
Return Value
This instance of
WriteBatch. Used for chaining method calls. -
Encodes an instance of
Encodableand writes the encoded data to the document referred bydocby only replacing the fields specified undermergeFields. Any field that is not specified in mergeFields is ignored and remains untouched. If the document doesn’t yet exist, this method creates it and then sets the data.It is an error to include a field in
mergeFieldsthat does not have a corresponding field in theEncodable.See
Firestore.Encoderfor more details about the encoding process.Declaration
Swift
@discardableResult func setData<T: Encodable>(from value: T, forDocument doc: DocumentReference, mergeFields: [Any], encoder: Firestore.Encoder = Firestore .Encoder()) throws -> WriteBatchParameters
valueAn instance of
Encodableto be encoded to a document.docThe document to create/overwrite the encoded data to.
mergeFieldsArray of
StringorFieldPathelements specifying which fields to merge. Fields can contain dots to reference nested fields within the document.encoderThe encoder instance to use to run the encoding.
Return Value
This instance of
WriteBatch. Used for chaining method calls.