猫鼬子文档排序



这实际上是两个问题。

使用MongooseJS

  1. 可以为架构设置默认排序顺序吗?
  2. 你能控制子文档如何排序吗?

查看可用于模式创建的选项,看起来这不是一个可用的选项:

autoIndex: bool - defaults to true
bufferCommands: bool - defaults to
true capped: bool - defaults to false
collection: string - no default
id: bool - defaults to true
_id: bool - defaults to true
minimize: bool - controls document#toObject behavior when called manually - defaults to true
read: string
safe: bool - defaults to true.
shardKey: bool - defaults
to null strict: bool - defaults to true toJSON - object - no default
toObject - object - no default
versionKey: bool - defaults to "__v"

你也许可以做一个插件来完成你想做的事情。

最新更新