Skip to main content

index_key_to_bson

Function index_key_to_bson 

Source
pub fn index_key_to_bson(
    index: &str,
    field: &str,
    value: &ParseValue,
) -> Result<Bson, ParseError>
Expand description

Lower one entry of an index key document.

Deliberately narrow. Mongo accepts a number for a sort direction and a string for an index type, and nothing else belongs in a key document. Anything else is refused rather than passed through, because createIndexes would answer with a driver message this layer must not put on the wire, and because the value is about to be written into _metadata.indexes where a parse-server node reads it back.

Upstream does no validation here at all: setIndexesWithSchemaFormat checks the field names against the schema (MongoStorageAdapter.js:377-390) and hands the values straight to the driver. The direction of this divergence is refusing something upstream would have let the driver refuse, and the code and message are the same either way.