0

If I have two objects Project and Task associated with one-to-many relation

 Project.hasMany(Task)     
 var Pro1 = Project.build({...}).save();

Now when I set a new task to one person after saving it

var task = Task.build({ ... }).save().success(function(t1)){
     project.setTasks([t1]).success(function() {
            // saved!
      })
})

the first task works fine, but with the second task I get the following error

TypeError: Cannot read property 'omitNull' of undefined
    at  {myhome}/node_modules/sequelize/lib/associations/has-many-single-linked.js:21:65

How can add more tasks to the previous, and be able to get them later with

Pro1.getTASKs
4

2 回答 2

1

sadly your code is kinda strange, as you are using different variable names in those three code examples. However, this is how you would do it: https://gist.github.com/3040391

In order to add other tasks you can do project.addTask(myNewTask)

于 2012-07-03T15:22:06.420 回答
0

this issue is fixed in 1.5.0-beta :) go for it!

于 2012-07-05T16:05:42.667 回答