const mixinafMorphia::BsonConvs

afMorphia::BsonConvs

(Service) - Converts Fantom objects to and from their BSON representation.

defConvs

Source

static Type:BsonConv defConvs()

The default set of BSON <-> Fantom converters.

fromBsonDoc

Source

abstract Obj? fromBsonDoc([Str:Obj?]? bsonObj, Type? fantomType := null)

Converts a BSON object to the given Fantom type.

Convenience for calling fromBsonVal() with a cast. If fantomType is null then the obj is inspected for a _type property.

fromBsonVal

Source

abstract Obj? fromBsonVal(Obj? bsonVal, Type? fantomType := null)

Converts a BSON value to the given Fantom type. If fantomType is null then the obj is inspected for a _type property, else a reasonable guess is made (and the option docToTypeFn is then called as a last resort.)

bsonVal is nullable so converters can choose whether or not to create empty lists and maps.

get

Source

@Operator
abstract BsonConv get(Type type)

Returns the Converter instance used to convert the given type.

make

Source

static new make([Type:BsonConv]? converters := null, [Str:Obj?]? options := null)

Returns a new BsonConvs instance.

If converters is null then defConvs is used. Some defaults are:

pickleMode        : false
makeEntityFn      : |Type type, Field:Obj? fieldVals->Obj?| { BeanBuilder.build(type, vals) }
makeBsonObjFn     : |->Str:Obj? |    { Str:Obj?[:] { ordered = true } }
makeMapFn         : |Type t->Map|    { Map((t.isGeneric ? Obj:Obj?# : t).toNonNullable) { it.ordered = true } }
docToTypeFn       : |Str:Obj?->Type| { null }
storeNullFields   : false
strictMode        : false
propertyCache     : BsonPropCache()

Override makeEntityFn to have IoC create entity instances.

Set strictMode to true to Err if the BSON contains unmapped data.

pickleMode is where all non @Transient fields are converted, regardless of any @BsonProp facets. Data from @BsonProp facets, however, will still honoured if defined.

propertyCache

Source

abstract BsonPropCache propertyCache()

Returns the BsonPropCache which stores @BsonProp meta for Types.

toBsonDoc

Source

abstract [Str:Obj?]? toBsonDoc(Obj? fantomObj)

Converts the given Fantom object to its BSON object representation.

Convenience for calling toBsonVal() with a cast.

toBsonVal

Source

abstract Obj? toBsonVal(Obj? fantomObj, Type? fantomType := null)

Converts the given Fantom object to its BSON representation.

fantomObj is nullable so converters can create empty / default objects. fantomType in case fantomObj is null, but defaults to fantomObj?.typeof.

withOptions

Source

abstract BsonConvs withOptions(Str:Obj? newOptions)

Returns a new BsonConvs whose options are overridden with the given ones.