Optional
transform: TransformFunction<DT, AT>transform
allows you to pass a function that transforms values from db format to api
format and back. For example, the database might store booleans in number format, while the
API presents them in native boolean format. Or the database might return full dates while the
api presents unix timestamps. This function allows you to handle such translations.
Protected
dbProtected
apiProtected
apiProtected
defaultProtected
Optional
transformtransform
allows you to pass a function that transforms values from db format to api
format and back. For example, the database might store booleans in number format, while the
API presents them in native boolean format. Or the database might return full dates while the
api presents unix timestamps. This function allows you to handle such translations.
Optional
logger: SimpleLoggerInterfaceOptional
logger: SimpleLoggerInterfaceGenerated using TypeDoc
Translators perform the work of translating data between database format and api format[1]. They are instantiated with an api prefix (e.g., '/registry/v3', '/brokerage/v2', etc...), a default type, a spec, and an optional tranform function[2]. It is intended that each service will maintain a library of resource translators that can be used throughout the service.
Example
Footnotes
transform
, see below) that serves to transform attribute data between database and api formats. Because of this, it is imperitive that you double-check the output of your Translators using unit tests.transform
param allows you to transform values between api and db format. For example, you may store boolean values as TINYINT in the database, or uuid values as BINARY(16) in the database. You can use thetransform
function to perform these transformations in each direction.