@cbnsndwch/zero-sources

DocumentPath type

Home > @cbnsndwch/zero-contracts > DocumentPath

DocumentPath type

Represents a document path identifier that must start with a dollar sign ($) followed by a field name.

This type enforces that document paths follow MongoDB's field reference convention where they are prefixed with '$'. The path after the $ can use dot notation for nested fields.

Signature:

type DocumentPath = `$${string}`;

Example

const validPath: DocumentPath = '$_id'; // Top-level field
const nestedPath: DocumentPath = '$user.name'; // Nested field
const deepPath: DocumentPath = '$address.city.zipCode'; // Deeply nested

How was this page?