SchemaDateOptions
SchemaDateOptions()
SchemaDateOptions.prototype.expires
SchemaDateOptions.prototype.max
SchemaDateOptions.prototype.min
SchemaDateOptions()
類型 (Type)
- «建構子»
繼承 (Inherits)
在日期模式類型上定義的選項。
範例
const schema = new Schema({ startedAt: Date });
schema.path('startedAt').options; // SchemaDateOptions instance
SchemaDateOptions.prototype.expires
類型 (Type)
- «Date»
如果設定,Mongoose 會在此路徑上建立 TTL 索引。
mongo TTL 索引 expireAfterSeconds
的值將採用以秒為單位的 'expires' 值。
範例
const schema = new Schema({ "expireAt": { type: Date, expires: 11 } });
// if 'expireAt' is set, then document expires at expireAt + 11 seconds
SchemaDateOptions.prototype.max
類型 (Type)
- «Date»
如果設定,Mongoose 會新增一個驗證器,檢查此路徑是否在給定的 max
之前。
SchemaDateOptions.prototype.min
類型 (Type)
- «Date»
如果設定,Mongoose 會新增一個驗證器,檢查此路徑是否在給定的 min
之後。