Mongoose子文档排序

时间:2013-04-24 18:13:31

标签: javascript node.js express mongoose

这实际上是两个问题。

使用MongooseJS

  1. 您可以设置架构的默认排序顺序吗?
  2. 你能控制子文档的排序方式吗?

1 个答案:

答案 0 :(得分:0)

查看options available for Schema creation,看起来这不是一个可用选项:

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"

您可以制作plugin来完成您尝试做的事情。