const mixinafMorphia::BsonConvs
afMorphia::BsonConvs
(Service) - Converts Fantom objects to and from their BSON representation.
- defConvs
static Type:BsonConv defConvs()The default set of BSON <-> Fantom converters.
- fromBsonDoc
abstract Obj? fromBsonDoc([Str:Obj?]? bsonObj, Type? fantomType)Converts a BSON object to the given Fantom type.
Convenience for calling
fromBsonVal()with a cast.- fromBsonVal
abstract Obj? fromBsonVal(Obj? bsonVal, Type? fantomType)Converts a BSON value to the given Fantom type. If
fantomTypeisnullthennullis always returned.bsonValis nullable so converters can choose whether or not to create empty lists and maps.- get
@Operator
abstract BsonConv get(Type type)Returns the
Converterinstance used to convert the given type.- make
static new make([Type:BsonConv]? converters := null, [Str:Obj?]? options := null)Returns a new
BsonConvsinstance.If
convertersisnullthendefConvsis used. Common options are:makeEntityFn : |Type type, Field:Obj? fieldVals->Obj?| { BeanBuilder.build(type, vals) } storeNullFields : false strictMode : false propertyCache : BsonPropCache()Override
makeEntityto have IoC create entity instances. SetstrictModetotrueto Err if the BSON contains unmapped data.Serializable Mode is where all non-transient fields are converted, regardless of any
@BsonPropfacets. Data from@BsonPropfacets, however, is still honoured if defined.- propertyCache
abstract BsonPropCache propertyCache()Returns the
BsonPropCache.- toBsonDoc
abstract [Str:Obj?]? toBsonDoc(Obj? fantomObj)Converts the given Fantom object to its BSON object representation.
Convenience for calling
toBsonVal()with a cast.- toBsonVal
abstract Obj? toBsonVal(Obj? fantomObj, Type? fantomType := null)Converts the given Fantom object to its BSON representation.
fantomObjis nullable so converters can create empty / default objects.fantomTypein casefantomObjis null, but defaults tofantomObj?.typeof.- withOptions
abstract BsonConvs withOptions(Str:Obj? newOptions)Returns a new
BsonConvswhose options are overridden with the given ones.