TypeRegistry constructor

TypeRegistry({
  1. Map<int, Codec>? codecs,
  2. Iterable<EncoderFn>? encoders,
})

Implementation

TypeRegistry({
  /// Override or extend the built-in codecs using the type OID as key.
  Map<int, Codec>? codecs,

  /// When encoding a non-typed parameter for a query, try to use these
  /// encoders in their specified order. The encoders will be called
  /// before the the built-in (generic) text encoders.
  Iterable<EncoderFn>? encoders,
}) {
  _bySubstitutionName.addAll(_builtInTypeNames);
  _codecs.addAll(_builtInCodecs);
  for (final type in _builtInTypes) {
    if (type.oid != null && type.oid! > 0) {
      _byTypeOid[type.oid!] = type;
    }
  }
  if (codecs != null) {
    _codecs.addAll(codecs);
  }
  _encoders.addAll([...?encoders, _defaultTextEncoder]);
}