【发布时间】:2013-04-18 10:25:51
【问题描述】:
这其实是两个问题。
使用 MongooseJS
- 能否为 Schema 设置默认排序顺序?
- 您能否控制子文档的排序方式?
【问题讨论】:
-
我不确定答案。我可以四处搜索,也许看看代码,但也许如果你解释你想要完成的事情,有人可以提供另一种方法。
标签: javascript node.js express mongoose
这其实是两个问题。
使用 MongooseJS
【问题讨论】:
标签: javascript node.js express mongoose
看看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 来完成您想做的事情。
【讨论】: