Add a model at the end of the collection.

@method push
@param {Model} model model or data to add
@param {object} [options] options for adding
@return {Model} Return the new added model
169271
function(model, options) {
            model = this._prepareModel(model, options);
            this.add(model, options);
            return model;
        }
1308765
function(models, options) {
      var i, args, length, model, existing, needsSort;
      var at = options && options.at;
      var sort = ((options && options.sort) == null ? true : options.sort);
      models = _.isArray(models) ? models.slice() : [models];

      // Turn bare objects into model references, and prevent invalid models
      // from being added.
      for (i = models.length - 1; i >= 0; i--) {
        if(!(model = this._prepareModel(models[i], options))) {
          this.trigger("error", this, models[i], options);
          models.splice(i, 1);
          continue;
        }
        models[i] = model;

        existing = model.id != null && this._byId[model.id];
        // If a duplicate is found, prevent it from being added and
        // optionally merge it into the existing model.
        if (existing || this._byCid[model.cid]) {
          if (options && options.merge && existing) {
            existing.set(model.attributes, options);
            needsSort = sort;
          }
          models.splice(i, 1);
          continue;
        }

        // Listen to added models' events, and index models for lookup by
        // `id` and by `cid`.
        model.on('all', this._onModelEvent, this);
        this._byCid[model.cid] = model;
        if (model.id != null) this._byId[model.id] = model;
      }

      // See if sorting is needed, update `length` and splice in new models.
      if (models.length) needsSort = sort;
      this.length += models.length;
      args = [at != null ? at : this.models.length, 0];
      push.apply(args, models);
      splice.apply(this.models, args);

      // Sort the collection if appropriate.
      if (needsSort && this.comparator && at == null) this.sort({silent: true});

      if (options && options.silent) return this;

      // Trigger `add` events.
      while (model = models.shift()) {
        model.trigger('add', model, this, options);
      }

      return this;
    }
635095
function(models, options) {
      var model, i, l, existing;
      var add = [], remove = [], modelMap = {};
      var idAttr = this.model.prototype.idAttribute;
      options = _.extend({add: true, merge: true, remove: true}, options);
      if (options.parse) models = this.parse(models);

      // Allow a single model (or no argument) to be passed.
      if (!_.isArray(models)) models = models ? [models] : [];

      // Proxy to `add` for this case, no need to iterate...
      if (options.add && !options.remove) return this.add(models, options);

      // Determine which models to add and merge, and which to remove.
      for (i = 0, l = models.length; i < l; i++) {
        model = models[i];
        existing = this.get(model.id || model.cid || model[idAttr]);
        if (options.remove && existing) modelMap[existing.cid] = true;
        if ((options.add && !existing) || (options.merge && existing)) {
          add.push(model);
        }
      }
      if (options.remove) {
        for (i = 0, l = this.models.length; i < l; i++) {
          model = this.models[i];
          if (!modelMap[model.cid]) remove.push(model);
        }
      }

      // Remove models (if applicable) before we add and merge the rest.
      if (remove.length) this.remove(remove, options);
      if (add.length) this.add(add, options);
      return this;
    }
98065
function (model, pojo, options) {
  pojo = pojo || {};

  let props = model.serializeProperties || model.properties;

  props = props.filter(prop => (!model.propertyOptions[prop] || model.propertyOptions[prop].serialize !== false));

  props.forEach(key => {
    let obj;

    let o = model.propertyOptions[key];

    if (o && o.preSerialize) {
      obj = o.preSerialize(options);
    } else {
      obj = model[key];
    }

    if (obj instanceof Array) {
      let newArr = [];

      obj.forEach(item => {
        newArr.push(item instanceof Model ? item.serialize() : item);
      });

      pojo[key] = newArr;
    } else if (obj instanceof Model) {
      pojo[key] = obj.serialize(options);
    } else {
      pojo[key] = obj;
    }

    if (o && o.postSerialize) {
      o.postSerialize(options);
    }
  });

  if (model.postSerialize) {
    model.postSerialize(pojo, options);
  }

  return pojo;
}
16083
function(model_s, create, options){
      var toAdd = model_s instanceof Array ? model_s : [model_s],
          self = this;

      ko.utils.arrayForEach(toAdd, function(attributes){
        var model;
        if(attributes instanceof Model){
          model = attributes;
          model.collection = self;
        }else{
          model = new self.model(attributes, {collection: self});
        }
        self.models.push(model);
        if(create) model.save(options);
      });
    }
853240
function(models, options) {
      if (_.isArray(models)) {
        for (var i = 0, l = models.length; i < l; i++) {
          this._add(models[i], options);
        }
      } else {
        this._add(models, options);
      }
      return this;
    }
67702
function modelQuery(options) {
            return models.Post.findOne(options.data, omit(options, ['data']))
                .then((model) => {
                    if (!model) {
                        return Promise.reject(new common.errors.NotFoundError({
                            message: common.i18n.t('errors.api.posts.postNotFound')
                        }));
                    }

                    return {
                        posts: [urlsForPost(model.id, model.toJSON(options), options)]
                    };
                });
        }
1024470
public function push(AbstractModel $model)
    {
        $this->validateAdd($model);
        if (true === $this->willAdd($model)) {
            return $this;
        }
        if (true === $this->willRemove($model)) {
            $this->evict('removed', $model);
            $this->set('models', $model);
            return $this;
        }
        if (true === $this->hasOriginal($model)) {
            return $this;
        }
        $this->set('added', $model);
        $this->set('models', $model);
        return $this;
    }
1213250
function modelQuery(options) {
            return models.Post.add(options.data.posts[0], omit(options, ['data']))
                .then((model) => {
                    const post = urlsForPost(model.id, model.toJSON(options), options);

                    if (post.status === 'published') {
                        // When creating a new post that is published right now, signal the change
                        post.statusChanged = true;
                    }

                    return {posts: [post]};
                });
        }
608129
function(_options){
      var self = this, //collection
          options = _options || {},
          success = options.success; //custom success function passed in _options

      options.success = function(data){
        var toAdd = [];

        for(var model in data){
          toAdd.push(data[model]);
        }

        self.reset(); //reset the collection
        if(toAdd.length > 0) self.add(toAdd);
        if(success) success(self, data);
      };

      return this.sync.call(this, 'fetch', this, options);
    }
605489
function(model, options) {
          model.id = Backbone.Firebase._getKey(this.firebase.push());
          options = _.extend({ autoSync: false }, options);
          return Backbone.Collection.prototype.create.apply(this, [model, options]);
        }
1284169
function putItem(model, options) {
	options || ( options = {} );
	if ( options.serializeDates !== false ) {
		// If serializeDates is NOT `false`, use `true` by default.
		options.serializeDates = true;
	}

	var newKey, // If the model `isNew`, a new key is generated.
		request,
		hashName, // Name of the hash attribute.
		rangeName, // Name of the range attribute.
		keyPromise,
		deferred = new _.Deferred(),
		/**
		 * Container object to store the attributes that are changed as part of saving the model.
		 */
		changed = {},
		/**
		 * Parameters to use in the DynamoDB PutItem request
		 */
		params = {
			/**
			 * Convert the model into an object.
			 * If `options.serializeDates` is `true`, `Date` values are converted into strings.
			 */
			Item: model.toJSON( options ),
			TableName: model._tableName()
		};

	if ( model.isNew() ) { // If the model is new, a new key attribute(s) must be generated
		hashName = _.result( model, 'hashAttribute' ) || _.result( model, 'idAttribute' );
		rangeName = _.result( model, 'rangeAttribute' );

		/**
		 * Convenience method to set the `newKey` attribute(s), once it's generated.
		 */
		function setNewKey(_newKey) {
			if ( rangeName ) {
				/**
				 * If the model has a range attribute, _newKey must be an object that contains
				 * the hash and range attributes.
				 */
				_.extend( changed, _newKey );
			} else {
				/**
				 * If the model doesn't have a range attribute, _newKey must be the value of the hash attribute.
				 */
				changed[ hashName ] = _newKey;
			}

			// Add the new key attribute(s) to the Item to be sent to DynamoDB
			_.extend( params.Item, options.serializeDates === true ? serializeAllDates( model, _.clone( changed ) ) : changed );
		}

		// Generate new key attribute(s)
		newKey = model.newKey( options );

		if ( isPromise( newKey ) ) {
			/**
			 * If `newKey` is a promise, wait until it's resolved to execute `setNewKey`
			 * and assign the resulting promise to `keyPromise`.
			 */
			keyPromise = newKey.then( setNewKey );
		} else {
			// If `newKey` is NOT a promise, call `setNewKey` right away.
			setNewKey( newKey );
		}
	}

	wrapComplete( model, options );
	_.extend( params, options.dynamodb );

	request = dynamo().putItem( params );

	request.on('complete', function (response) {
		var ctx = options.context || model;

		if ( response.error ) {
			deferred.rejectWith( ctx, [ response, options ] );
		} else {
			/**
			 * Backbone's "internal" success callback takes the changed attributes as the first argument.
			 * Make the entire AWS `response` available as `options.awsResponse`.
			 */
			options.awsResponse = response;
			deferred.resolveWith( ctx, [ changed, options ] );
		}
	});

	if ( !keyPromise ) {
		// If there's no `keyPromise`, send the request right away.
		request.send();
	} else {
		// If there's a `keyPromise`, wait until it is "done" before sending the request.
		keyPromise.done(function () {
			request.send();
		}).fail(function () {
			var ctx = options.context || model;
			deferred.rejectWith( ctx, arguments );
		});
	}

	deferred.done( options.success ).fail( options.error ).always( options.complete );

	return deferred.promise( request );
}
610769
function (model, options) {
        if (this === model.collection) delete model.collection;
        this._deIndex(model);
        if (model.off) model.off('all', this._onModelEvent, this);
    }
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;
        }
1226172
function(model) {
    this.localStorage().setItem(this.name+"-"+model.id, JSON.stringify(model));
    if (!_.include(this.records, model.id.toString()))
      this.records.push(model.id.toString()); this.save();
    return this.find(model);
  }
679646
function( options ){

			options 			= options || {};
			options.$db 		= cOptions.db;
			options.$dbName 	= cOptions.database;
			options.$model 		= cOptions.model;

			return new cOptions.cls( options );
		}
2194
function(model, options) {
      options || (options = {});
      model = this._prepareModel(model, options);
      if (!model) return false;
      var already = this.getByCid(model) || this.get(model);
      if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
      this._byId[model.id] = model;
      this._byCid[model.cid] = model;
      var index = options.at != null ? options.at :
                  this.comparator ? this.sortedIndex(model, this.comparator) :
                  this.length;
      this.models.splice(index, 0, model);
      model.bind('all', this._onModelEvent);
      this.length++;
      if (!options.silent) model.trigger('add', model, this, options);
      return model;
    }