I have a folder, that has index.js and a couple of models (classes)
index.js
module.exports = {
Book : require('./book'),
Author : require('./author')
}
book.js
var Author = require('./author')
var Book = models.ActiveRecord.extend({
schema : {
belongsTo : {
author : Author
}
}
})
module.exports = Book
author.js
var Book = require('./book')
var Author = models.ActiveRecord.extend({
schema : {
hasMany : {
author : Book
}
}
})
module.exports = Author
The problem is that Author class does not seem to find the Book! It's just an empty Object.
However, if I switch the exports in index.js, putting Book after Author - it works, but then the other model stops working.
I don't want to do any hacks to make it work.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…