ste*_*red 6 mongoose mongoose-schema
Mongoose版本> = 4.0有一个timestamps选项,当设置为时,它为模式创建一个updatedAt和createdAt字段.timestampstrue
http://mongoosejs.com/docs/guide.html#timestamps
是updatedAt和createdAt字段索引?
enR*_*ser 12
不,它们没有编入索引,您必须自己编制索引,就像任何其他字段一样.
animalSchema.index({"createdAt": 1});
animalSchema.index({"updatedAt": 1});
Run Code Online (Sandbox Code Playgroud)