【问题标题】:How can I get the full schema definition of a Mongoose collection?如何获得 Mongoose 集合的完整架构定义?
【发布时间】:2015-04-30 18:41:19
【问题描述】:

包括属性、类型等?我想要得到的,本质上是:

{
    label: {
        type: "String",
        required: true
    },
    published: {
        type: "Boolean",
        default: true
    }
}

调用mongoose.model('someModel').schema.paths 只返回StringNumberObjectId 的属性类型,所有其他都是undefined。当我在 GitHub 问题队列中阅读此内容时,似乎此信息(schema.paths[path].instance 属性)是内部信息,甚至不应该首先使用。

如果是这样,如何以编程方式获取架构定义?

没有回答的相关问题:

相关 GitHub 问题:

【问题讨论】:

  • 架构上的 tree 属性看起来非常接近。您也可以只保存原始架构定义对象。你最终想用这些信息做什么?

标签: mongoose


【解决方案1】:

这已合并到 Mongoose 4.0.0:https://github.com/Automattic/mongoose/issues/1938

【讨论】:

    猜你喜欢
    • 2020-06-12
    • 1970-01-01
    • 2018-02-23
    • 2016-06-20
    • 2021-07-10
    • 1970-01-01
    • 1970-01-01
    • 2014-09-14
    • 1970-01-01
    相关资源
    最近更新 更多