gpt4 book ai didi

node.js - module.export 不工作CompoundJS?

转载 作者:太空宇宙 更新时间:2023-11-03 23:45:10 24 4
gpt4 key购买 nike

我是CompoundJS 的新手。我正在开发一个示例应用程序。如果遵循以下教程:

Using Mongoose Models

我在 db/schema.js 文件中编写了以下代码:

customSchema(function () {

var mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/my_database');

var Schema = mongoose.Schema, ObjectId = Schema.ObjectId;

module.exports["mongoose"] = mongoose;

module.exports["model"] = {}

});

在我的 model.js 文件 (person.js) 中,我有以下代码:

   var Person = mongoose.model('Person', new module.schema());

model['Person'] = Person;

当我运行 compound s 时,我收到 ReferenceError: mongoose is not Defined。

任何帮助将不胜感激。提前致谢。

最佳答案

Wiki 已过时,所有文档当前均可在 http://compoundjs.com 获取,我将删除 wiki 以避免混淆。

如果您需要 mongoose 作为 ORM,您可以使用此示例:https://github.com/anatoliychakkaev/mongoose-compound-example-app

关于node.js - module.export 不工作CompoundJS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14438167/

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