Type Alias
ProjectedDocument
The type of the documents a query returns for a projection.
Without a projection it is WithId<TDocument>. When the projection's flags
are not literals, every field becomes optional because the result cannot be
known.
type ProjectedDocument<TDocument extends object, TProjection> = [TProjection] extends [undefined]
? WithId<TDocument>
: [UnknownPaths<TProjection>] extends [never]
? [IncludedPaths<TProjection>] extends [never]
? [Flagged<TProjection, 1 | true>] extends [never]
? [ExcludedPaths<TProjection>] extends [never]
? [Flagged<TProjection, 0 | false>] extends [never]
? WithId<TDocument>
: Simplify<Omit<TDocument, "_id">>
: Simplify<Drop<Omit<TDocument, "_id">, ExcludedPaths<TProjection>> & IdPart<TProjection>>
: { readonly _id: CustomId }
: Simplify<Keep<Omit<TDocument, "_id">, IncludedPaths<TProjection>> & IdPart<TProjection>>
: Partial<WithId<TDocument>>Defined in packages/driver/src/projection.ts:147