Skip to main content

Module transform

Module transform 

Source
Expand description

Parse JSON to BSON and back.

Upstream: src/Adapters/Storage/Mongo/MongoTransform.js. It is full of load-bearing special cases, and those special cases are the whole job: the naive transform is trivial and wrong.

The pair implemented here mirrors parseObjectToMongoObjectForCreate and mongoObjectToParseObject, which are the two functions upstream exports and therefore the two this can be differentially tested against. See tests/transform_differential.rs.

Scope is the 0.1.0 field set: String, Number, Boolean, Date, Array, Object, Pointer, ACL, plus the 0.2.0 additions: the $or/$and/$nor query tree, $all, $regex, the update operator set, and Relation fields (which have no column at all).

Functionsยง

bson_document_to_parse_map
Raise a stored sub-document into Parse form, verbatim.
bson_to_parse_value
Raise a stored value. Takes no schema: the stored form is self-describing, which is the asymmetry with lowering, where the schema decides whether a field is a _p_ pointer.
index_key_to_bson
Lower one entry of an index key document.
mongo_object_to_parse
mongoObjectToParseObject.
parse_map_to_bson_document
Lower a Parse map into a stored sub-document, applying no policy.
parse_object_to_mongo_create
parseObjectToMongoObjectForCreate.
storage_key
Keys that are renamed rather than stored under their Parse name (transformKey, MongoTransform.js:7-30). The list is closed: everything else keeps its name, except a declared Pointer field, which takes a _p_ prefix.
transform_update
transformUpdate: lower an update AST into a Mongo update document.
transform_where
transformWhere: lower a query tree into a Mongo filter document.
value_to_bson_for_query
Lower a value for use in a query filter on field.