gpt4 book ai didi

javascript - Mongoose 子文档排序

转载 作者:搜寻专家 更新时间:2023-11-01 00:08:49 24 4
gpt4 key购买 nike

这其实是两个问题。

使用 Mongoose

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

最佳答案

查看 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完成你想要做的事情。

关于javascript - Mongoose 子文档排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16199283/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com