Skip to main content

MONGO_ID

Constant MONGO_ID 

Source
pub const MONGO_ID: &str = "_id";
Expand description

The key MongoDB stores a record’s id under.

The SERVER’s name and not this framework’s: MongoDB mints an _id for every document that arrives without one and indexes it uniquely, so a document carrying that beside a declared id would be one row with two identities and the wrong one indexed.

It is a &str here and again in ingraph’s own comparison::mongo::ID, which are two crates and therefore two constants — the emitter cannot name a runtime item of the framework in a string literal, and the framework cannot depend on the emitter. What keeps them one fact is that each has ONE reader: this one is spent by DatabaseBackend::external, and that one by field_key. ingraph-codegen’s own tests::the_mongo_document_reads_the_id_out_of_underscore_id reads the emitted spelling back.