簡體   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