module.export不工作CompoundJS?
我是CompoundJS的新手。 我正在做一个示例应用程序。 如果按照以下教程:
使用mongoose模型
我已经在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;
当我运行复合的时候 ,我得到了ReferenceError:没有定义mongoose。
任何帮助将是可观的。 提前致谢。
维基已经过时,所有的文档目前可在http://compoundjs.com ,我将删除维基,以避免混淆。
如果你需要mongoose作为ORM,你可以使用这个例子: https : //github.com/anatoliychakkaev/mongoose-compound-example-app