I am trying to save a one to many relation My models are
Foo
foo = bookshelf.Model.extend({
tableName: 'foo',
bar: function () {
return this.hasMany('bar', 'barId');
}
Bar
bar = bookshelf.Model.extend({
tableName: 'bar',
foo: function () {
return this.belongsTo('foo', 'barId');
}
What I am trying to do
var Foo = { id: 7 }
new Bar({ blah: blah.val })
.foo()
.attach(foo);
The error I am getting
(intermediate value).foo().attach is not a function
Any help will be appreciated.