property MongoEntityMapping.idType

How the collection stores its _id values.

  • 'objectId' forces the id to a driver ObjectId on read and write.
  • 'raw' forbids conversion, so a string id is passed to the driver verbatim.
  • 'compound' stores a composite key as a subdocument _id, built in the mapping's declared column order (P5 — canonical order, not caller order). Absent converts a string id that ObjectId.isValid accepts — a 24-hex string. A non-string id (a number key) is passed through verbatim, because the driver's isValid answers true for any number while its constructor rejects one.

The genuinely ambiguous collection — one whose _id values are 24-hex strings rather than ObjectIds — cannot be distinguished at runtime, so the override exists rather than being guessed.

Type

"objectId" | "raw" | "compound"

Usage

import { type MongoEntityMapping } from "database-plugin/src/index.ts";