Add a 'model' to it's appropriate collection. Retain the original contents of 'model.collection'.
@param {Backbone.RelationalModel} model
170587
function( model ) {
			var coll = this.getCollection( model );

			if ( coll ) {
				if ( coll.get( model ) ) {
					throw new Error( "Cannot instantiate more than one Backbone.RelationalModel with the same id per type!" );
				}

				var modelColl = model.collection;
				coll.add( model );
				model.bind( 'destroy', this.unregister, this );
				model.collection = modelColl;
			}
		}
380008
function(model) {
			if (model === this._model) { return; }
			model = model || new mTextModel.TextModel();
			this._model.removeEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$
			this._model.removeEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$
			var oldLineCount = this._model.getLineCount();
			var oldCharCount = this._model.getCharCount();
			var newLineCount = model.getLineCount();
			var newCharCount = model.getCharCount();
			var newText = model.getText();
			var e = {
				type: "ModelChanging", //$NON-NLS-1$
				text: newText,
				start: 0,
				removedCharCount: oldCharCount,
				addedCharCount: newCharCount,
				removedLineCount: oldLineCount,
				addedLineCount: newLineCount
			};
			this.onModelChanging(e);
			this._model = model;
			e = {
				type: "ModelChanged", //$NON-NLS-1$
				start: 0,
				removedCharCount: oldCharCount,
				addedCharCount: newCharCount,
				removedLineCount: oldLineCount,
				addedLineCount: newLineCount
			};
			this.onModelChanged(e); 
			this._model.addEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-1$
			this._model.addEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-1$
			this._reset();
			this._update();
		}
597096
function Model(collectionName, attributes, values) {
    this.collectionName = collectionName;
    this.idAttribute = Model.getId(attributes);
    this.attributes = attributeValidator.validate(attributes);
    this.values = { };
    this.virtuals = { };

    // initially add the null value from all attributes
    for (var key in this.attributes) {
        this.values[key] = undefined;
    }

    // prevents from modifying values and adding properties
    Object.freeze(this.attributes);

    // prevents from adding new properties
    Object.seal(this.values);

    // sets the initial values
    this.set(values);
}
1202016
def add(model)
      documents = Util.Array(model).map { |m| prepare_full_update(m) }
      add_batch_documents(documents)
    end
50872
function( model, options ) {
			if ( this.related ) {
				return;
			}
			options = this.sanitizeOptions( options );
			
			var item = this.keyContents;
			if ( item && ( _.isString( item ) || _.isNumber( item ) || typeof( item ) === 'object' ) ) {
				var id = _.isString( item ) || _.isNumber( item ) ? item : item[ this.relatedModel.prototype.idAttribute ];
				if ( model.id === id ) {
					this.addRelated( model, options );
				}
			}
		}
947206
function (model) {

                var ret = [];

                function getSubModel(obj) {

                    if (obj === model) {
                        return;
                    }

                    if (_.indexOf(ret, obj) !== -1) {
                        // already in list
                        return;
                    }

                    if (obj instanceof Model) {
                        ret.push(obj);
                        return;
                    }

                    for (var key in obj) {
                        if (obj.hasOwnProperty(key)) {
                            var value = obj[key];

                            if (value instanceof Array) {
                                for (var i = 0; i < value.length; i++) {
                                    getSubModel(value[i]);
                                }
                            } else if (value instanceof List) {
                                value.each(getSubModel);
                            } else if (value instanceof Object) {
                                getSubModel(value);
                            }
                        }
                    }
                }

                getSubModel(model.$);

                return ret;

            }
4660
function expandModel (model, view) {
  const modelPath = new BunsenModelPath(model)
  const modelExpansions = aggregateModels(view, modelPath)
  let newModel = model
  _.forEach(modelExpansions, (propertyModel, path) => {
    newModel = addBunsenModelProperty(newModel, propertyModel, path)
  })
  return newModel
}
1155386
function (model, options, eventName) {
        var newModels = slice.call(this.models);
        var comparator = this.comparator || this.collection.comparator;
        //Whether or not we are to expect a sort event from our collection later
        var sortable = eventName === 'add' && this.collection.comparator && (options.at == null) && options.sort !== false;
        if (!sortable) {
            var index = sortedIndexBy(newModels, model, comparator);
            newModels.splice(index, 0, model);
        } else {
            newModels.push(model);
            if (options.at) newModels = this._sortModels(newModels);
        }

        this.models = newModels;
        this._addIndex(this._indexes, model);
        if (this.comparator && !sortable) {
            this.trigger('sort', this);
        }
    }
1130002
function (id, cb) {
    var self = this;
    var idObj = {};
    idObj[this.model.prototype.idAttribute] = id;
    var model = new this.model(idObj, {collection: this});
    model.fetch({
      callback: function (err) {
        if(err){
          delete model.collection;
          if (cb){
            cb(Error('not found'));
          }
          return;
        }
        self.add(model);
        if (cb){
          return cb(null, model);
        }
      }
    });
  }
968269
function ( model ) {
                var trailing = this.collection.trailing && this.collection.trailing.id || this.collection.first().id,
                    view = this,

                    cbUpdateTrailing = function () {
                        view.collection.get( Math.round( this.trailingId ) ).select( { label: "trailing" } );
                    };

                // Animate the trailing element and make it catch up. Use the .select() method with the label
                // "trailing".
                $( { trailingId: trailing } ).animate(
                    { trailingId: model.id },
                    { step: cbUpdateTrailing, done: cbUpdateTrailing, duration: trailingLag }
                );
            }
1002432
function(model, options) {
            var index, existing;

            if (_.isArray(model)) {
                return _.map(model, function(m) {
                    return this.add(m, _.clone(options));
                }, this);
            }

            // Manage {list:[], n:0} for infinite list
            if (_.size(model) == 2
            && model.list != null && model.n != null) {
                this._totalCount = model.n;
                return this.add(model.list, options);
            }

            options = _.defaults({}, options || {}, {
                at: this.models.length,
                merge: false,
                silent: false
            });

            model = this._prepareModel(model);

            if (existing = this.get(model)) {
                if (options.merge) {
                    existing.set(model.toJSON())
                }
                return this;
            }

            this._byId[model.id] = model;

            this.listenTo(model, 'all', this._onModelEvent);
            this.listenTo(model, 'id', this._onModelId);

            index = options.at;
            this.models.splice(index, 0, model);

            if (options.silent) return this;
            options.index = index;
            this.trigger('add', model, this, options);

            if (this.comparator) this.sort({silent: options.silent});
            return model;
        }
1188609
function(view, options) {
        options = _.extend({}, defaultOptions, defaultCallbacks, options);

        var model = options.model || view.model,
            collection = options.collection || view.collection;

        if(typeof model === 'undefined' && typeof collection === 'undefined'){
          throw 'Before you execute the binding your view must have a model or a collection.\n' +
                'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
        }

        if(model) {
          bindModel(view, model, options);
        }
        else if(collection) {
          collection.each(function(model){
            bindModel(view, model, options);
          });
          collection.bind('add', collectionAdd, {view: view, options: options});
          collection.bind('remove', collectionRemove);
        }
      }
941371
protected function saveHasOneRelations(Model $model)
    {
        foreach ($model->getRelations() as $name => $relation) {
            if ($model->{$name}() instanceof HasOneOrMany && ! is_null($relation)) {
                if (is_array($relation) || $relation instanceof \Traversable) {
                    $model->{$name}()->saveMany($relation);
                } else {
                    $model->{$name}()->save($relation);
                }
            }
        }
    }
521849
function(model, options) {
    options = options ? extend({}, options) : {};
    if (!(model = this._prepareModel(model, options))){
      return false;
    }
    if (!options.wait){
      this.add(model, options);
    }
    var collection = this;
    options.cb = options.callback;
    options.callback = function cb(err, model, response){
      if (err){
        return callback(err, model, response, options);
      }
      if (options.wait){
        collection.add(model, options);
      }
      callback(null, model, response, options);
    };

    model.save(null, options);
    return model;
  }
931914
function addProperty (model, key, field_definition) {
	var property = {
		get : function() {
			return this['_' + key];
		},
		set : function(value) {
			this._updated_fields[key] = value;
			// should we track old values here and revert them on save error?
			this['_' + key] = value;
		}
	};

	if (field_definition.get) {
		property.get = field_definition.get;
	}

	if (field_definition.set) {
		property.set = function (value) {
			field_definition.set.call(this, value);
			this._updated_fields[key] = this['_' + key];
		};
	}			

	Object.defineProperty(model.prototype, key, property);
}
48009
function(model, options) {
      model = this._prepareModel(model, options);
      this.add(model, _.extend({at: 0}, options));
      return model;
    }
556735
public function setModel(Model $model)
    {
        parent::setModel($model);

        if ($model->exists) {
            $this->setInstance($model);
            $this->loadRelationValues();
        }
    }