Class MongoDBConverter
java.lang.Object
org.nuxeo.ecm.core.storage.mongodb.MongoDBConverter
Converts between MongoDB types (bson) and DBS types (diff, state, list, serializable).
The MongoDB native "_id" can optionally be translated into a custom id in memory (usually "ecm:id"). Otherwise it is stripped from returned results.
- Since:
- 9.1
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
class
Update list builder to prevent several updates of the same field. -
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructor for a converter that does not map the MongoDB native "_id".Constructor for a converter that also knows to optionally translate the native MongoDB "_id" into a custom id. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
bsonToSerializable
(String key, Object val) Class<?>
bsonToSerializableClass
(String key, Class<?> klass) bsonToState
(org.bson.Document doc) bsonToValue
(String key, Object value) diffToBson
(State.StateDiff diff) Constructs a list of MongoDB updates from the givenState.StateDiff
.org.bson.conversions.Bson
<T> org.bson.conversions.Bson
filterIn
(String key, Collection<T> values) getFromBson
(org.bson.Document doc, String bsonKey, String key) protected Object
listToBson
(String key, Collection<T> values) void
serializableToBson
(String key, Object value) org.bson.Document
stateToBson
(State state) protected boolean
valueToBson
(String key, Object value)
-
Field Details
-
idKey
The key to use in memory to map the database native "_id". -
trueOrNullBooleanKeys
The keys for booleans whose value is true or null (instead of false). -
idValuesKeys
The keys whose values are ids and are stored as longs. -
HEX_RE
-
-
Constructor Details
-
MongoDBConverter
public MongoDBConverter()Constructor for a converter that does not map the MongoDB native "_id".- Since:
- 10.3
-
MongoDBConverter
Constructor for a converter that also knows to optionally translate the native MongoDB "_id" into a custom id.When
idValuesKeys
are provided, the ids are stored as longs.- Parameters:
idKey
- the key to use to map the native "_id" in memory, if notnull
trueOrNullBooleanKeys
- the keys corresponding to boolean values that are only true or null (instead of false)idValuesKeys
- the keys corresponding to values that are ids
-
-
Method Details
-
diffToBson
Constructs a list of MongoDB updates from the givenState.StateDiff
.We need a list because some cases need two operations to avoid conflicts.
-
putToBson
-
keyToBson
-
valueToBson
-
stateToBson
-
listToBson
-
filterEq
-
filterIn
-
getFromBson
-
bsonToKey
-
bsonToState
-
bsonToValue
-
valueIsId
-
serializableToBson
-
bsonToSerializable
-
bsonToSerializableClass
-
idToBson
-
bsonToId
-