繁体   English   中英

Mongoose子文档排序

[英]Mongoose subdocuments sort

这实际上是两个问题。

使用MongooseJS

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

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

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"

您可以创建一个插件来完成您尝试做的事情。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM