2026-08-22
新!
NestJS 中的 Criteria 模式:客戶端可能要求的是一份檔案,而不是一個簽名
NestJS 中的 Criteria 模式
單一方式來過濾、排序與分頁任何清單。
五個參數與一個 find()
貫穿本文的範例是一個圖書館目錄。一本書會儲存以下內容:
// src/book/book.schema.ts
@Schema({ timestamps: true })
export class Book {
@Prop() title: string;
@Prop({ type: Types.ObjectId, ref: "Author" }) author: Types.ObjectId;
@Prop() publishedAt: Date;
@Prop() copies: number; // copies on the shelf
@Prop() available: