Protocol
DatabaseInput
AnyDatabaseProperty protocol.protocol DatabaseInput
Overview
All types conforming to either Fields or AnyDatabaseProperty provide an input(to:) method (see input(to:) and input(to:)). This method in turn calls the set(_:at:) method of the provided DatabaseInput once for each FieldKey the implementing type is responsible for, providing both the key and the DatabaseQuery.Value associated with that key.
As the protocol name suggests, the primary purpose of DatabaseInput is to allow a complete set of data, in the form of a key-value map, to be generically gathered for input “into” a database. However, to allow useful semantics such as composition (such as transparently remapping field keys) and alternate data handling (such as saving existing state so it can be temporarily overwritten), this mechanism is expressed as a protocol rather than just handing around a dictionary or other similar structure.
To Do
Define a new protocol formalizing the input(to:) and output(from:) methods found on both AnyDatabaseProperty and Fields, and have them conform to it rather than independently providing identical requirements. This will allow inputtable and outputtable (corresponding to encodable and decodable) types to be generically addressed cleanly.
See Also
Topics
Instance Properties
wantsUnmodifiedKeysIndicates whether thisDatabaseInputinstance is requesting key/value pairs for all defined database fields regardless of status, or only those pairs where the current value is known to be out of date (also referred to variously as “dirty”, “modified”, or “has changes”).
Instance Methods
prefixed(by:)Return aDatabaseInputwrappingselfso as to apply a given prefix to each field key before processing.prefixed(by:using:)Return aDatabaseInputwrappingselfso as to apply a given prefix, according to a givenKeyPrefixingStrategy, to each field key before processing.set(_:at:)Called by individual database properties to register a given field key and associated database value as part of the data set represented by theDatabaseInput.