-
Notifications
You must be signed in to change notification settings - Fork 369
Closed
Labels
Description
Hi, I write this little test to explain my issue:
var orm = require('orm');
orm.connect("mysql://root@127.0.0.1/test?debug=true", function (err, db){
console.log("CONNECTED TO DATABASE");
///////////////////////
// CREATE THE PARENT
///////////////////////
var Person = db.define('person', {
name : String
});
///////////////////////
// CREATE THE CHILD
///////////////////////
var Animal = db.define('animal', {
name : String
});
///////////////////////
// LINK THEM UP
///////////////////////
Person.hasMany("pets", Animal,{}, {
autoFetch: true
});
///////////////////////
// Sync
///////////////////////
db.sync(function(){
console.log("SYNC'D DB `test`");
///////////////////////
// Test insert
///////////////////////
var John = new Person();
John.name = "John";
John.save(function(err,obj){
if(err)
console.log("err: " + err);
console.log(obj);
console.log("END");
});
});
});
When I execute this code, I have the error:
No associations defined
But when I remove the autoFetch option, it working correctly. Can you help me, please.
Reactions are currently unavailable