Multiple relations (Javascript)

How to set multiple relations? I have 1:n relation type, but every time, when i’m adding new item, previous relation was replaced by newest.
My data table has field:
third
RELATION TO:Third

vm.data = {
 third: []
}



var dataStorage = Backendless.Data.of('data');
var thirdStorage = Backendless.Data.of('Third');



HomeService
 .saveThird(newItem)
 .then(function (resp) {
 dataStorage.setRelation(vm.data, 'third:Third:n', [ resp ]);
 });

Hi,

you are using ‘setRelation’ which always set relation from scratch. To add relations use ‘addRelation’ API
https://backendless.com/docs/js/doc.html#add-relation-with-objects

Regards,
Stanislaw

oh, thanks) Works fine

dataStorage.addRelation(vm.data.objectId, 'third', [ resp ]);