Skip to main content

Module storage_format

Module storage_format 

Source
Expand description

The _SCHEMA document format.

This is the one place where a mistake breaks a mixed fleet silently rather than loudly, so it gets its own module and its own round-trip tests.

A _SCHEMA document is {_id: <className>, <field>: <short type string>, ...} plus _metadata and _client_permissions. The type strings are terse and lossy-looking but exact: parseFieldTypeToMongoFieldType (MongoSchemaCollection.js:126-152) going down, and mongoFieldToParseSchemaField (:4-39) coming back.

Two hazards, both silent:

  • Never add a key. parse-server reads an unknown top-level _SCHEMA key as a phantom field, so a key parse-rust invents for bookkeeping becomes a real column on every parse-server node reading the same database.
  • Never invent a type string. mongoFieldToParseSchemaField is a switch with no default case, so an unrecognised type falls off the end and the field’s parsed entry becomes undefined, with no error anywhere.

Constants§

NON_FIELD_KEYS
Keys in a _SCHEMA document that are not fields (nonFieldSchemaKeys).

Functions§

field_type_to_storage
Lower a field type to its _SCHEMA string.
storage_to_field_type
Raise a _SCHEMA string back to a field type.