Attaching Detaching - JGdijk/ords GitHub Wiki
To attach a relation you use the function attach():
ords.use('task').attach(taskIds, relationName, relationIds);
ords.use('task').attach(1, 'project', [2,3,4]);
It is also possible to attach directly on a retrieved model:
ords.use('task').find(1).subscribe(task => {
this.task = task;
})
this.task.attach('project', 1);
To detach a relation you use the function detach():
ords.use('task').detach(taskIds, relationName, relationIds);
ords.use('task').detach(1, 'project', [2,3,4]);
It is also possible to detach directly on a retrieved model:
ords.use('task').find(1).subscribe(task => {
this.task = task;
})
this.task.detach('Project', 1);
You can also add a relation directly on a model with the addRelation() function, this will function as an add and attach in one.
ords.use('task').find(1).subscribe(task => {
this.task = task;
})
this.task.addRelation(relationName, object);