Skip to content

Options not passed along when performing CRUD actions #13

@johtso

Description

@johtso

It's currently not possible to silently reset a model with nested data, as any nested things created will be created noisily, as the options object with silent=true are not passed along.

I ended up doing this:

                             model.set(rModel.toJSON ? rModel.toJSON() : rModel);

                             // Remove the model from the incoming list because all remaining models
                             // will be added to the relation
                             modelsToAdd.splice(i,1);
                         } else {
                             modelsToRemove.push(model);
                         }

                     });

                     _.each(modelsToRemove, function(model) {
-                        relation.remove(model);
+                        relation.remove(model, options);
                     });

-                    relation.add(modelsToAdd);
+                    relation.add(modelsToAdd, options);

                 } else {

                     // The incoming val that is being set is not an array or collection, then it represents
                     // a single model.  Go through each of the models in the existing relation and remove
                     // all models that aren't the same as this one (by id). If it is the same, call set on that
                     // model.

                     relation.each(function(model) {
                         if(val[id] === model[id]) {
-                            model.set(val);
+                            model.set(val, options);
                         } else {
-                            relation.remove(model);
+                            relation.remove(model, options);
                         }
                     });
                 }

                 return relation;
             }

             if(relation && relation instanceof Model) {
-                relation.set(val);
+                relation.set(val, options);
                 return relation;
             }

             options._parent = this;

             val = new this.relations[attr](val, options);
             val.parent = this;
         }

         return val;
     };

Does that seem viable?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions