/*
Initializes a new instance of the @see OrganizationMethods class.
@param {Object} models A collection of models that can be used.
435400
function OrganizationMethods(models) {
      this.models = models;
      this.create = bind(this.create, this);
      this.patch = bind(this.patch, this);
      this.getByNameOrId = bind(this.getByNameOrId, this);
      this.getByName = bind(this.getByName, this);
      this.destroy = bind(this.destroy, this);
      this.get = bind(this.get, this);
      this.all = bind(this.all, this);
      Hoek.assert(this.models, i18n.assertModelsRequired);
      Hoek.assert(this.models.Organization, i18n.assertOrganizationInModelsRequired);
    }
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);
        }
    }
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);
      });
    }
251993
function applyModelFields (model, definition) {
	for (var field in definition.fields) {
		if (field === 'definition') {
			throw new Error('Invalid model definition provided. "definition" is a reserved word');
		}
		addProperty(model, field, definition.fields[field]);
	}
}
621984
function(models, options) {
      if (_.isArray(models)) {
        for (var i = 0, l = models.length; i < l; i++) {
          this._remove(models[i], options);
        }
      } else {
        this._remove(models, options);
      }
      return this;
    }
687349
public void init(Model model) {
	this.model = model;
	
	numLabels = model.taggerMaps.numLabels();
	
	Mi = new DoubleMatrix(numLabels, numLabels);
	Vi = new DoubleVector(numLabels);
	
	allocateMemory(100);
	
	// compute Mi once at initialization
	computeMi();
    }
498224
function(model){
        if (this.hasModel(model)) {
            // Clean up when removing so that it doesn't try removing itself from the collection
            this.detachModelEvents(model);

            this._models.erase(model);

            this.length = this._models.length;

            this._changed = true;
            
            this.signalRemove(model);
        }

        return this;
    }
469622
function (model) {
        var newModels = slice.call(this.models);
        var modelIndex = newModels.indexOf(model);
        if (modelIndex > -1) {
            newModels.splice(modelIndex, 1);
            this.models = newModels;
            this._removeIndex(this._indexes, model);
            return true;
        }
        return false;
    }
106529
func InitModels() {
	index := mgo.Index{
		Key:    []string{"key"},
		Unique: false,
	}

	db.EnsureIndex(mongoPersistenLogCollectionName, index)
}
200294
function (args) {
    Model.call(this, args);
    this.modelType = messageContents.modelType;
    this.attributes = [];
    for (var a in messageContents.attributes) {
      var attrib = new Attribute(messageContents.attributes[a].name, messageContents.attributes[a].type);
      if (attrib.name == 'id') { // TODO only If mongo! or refactor mongo to normalize IDs
        attrib.value = messageContents.attributes[a].value;
      } else {
        attrib.value = messageContents.attributes[a].value;
      }
      this.attributes.push(attrib);
    }
  }
63604
function initModelUpdate (args) {
    var controller = this
    var model = this.model
    // if model does not have id column then cannot use default controller
    if (!model.columnName('id') || !model.columnName('parentId')) {
        return
    }
    // get accountId column
    var accountIdColumn = model.columnName('accountId') 
    // set role to authenticated if model requires account id
    var role = args.defaultRole || (accountIdColumn && model.columns[accountIdColumn].null === false ? 'authenticated' : 'all')
    // index inputs
    var input = {
        // get current revision of instance
        current: 'query.current',
        // get record even if deleted
        deleted: 'query.deleted',
        // ignore conflicts
        force: 'query.force',
        // instance id
        id: 'params.id',
        // merge update data into existing data
        merge: 'query.merge',
        // input data includes meta columns
        meta: 'query.meta',
    }
    // instance data is in body under model name
    input[model.name] = 'body.'+model.name
    // create path for PUT for API requests
    if (!this.paths['/:id']) {
        this.paths['/:id'] = {}
    }
    // create path for POST for form requests
    if (!this.paths['/:id/update']) {
        this.paths['/:id/update'] = {}
    }
    // add handler for PUT /:id and POST /:id/update
    // to update instance
    this.paths['/:id'].put = this.paths['/:id/update'].post = [
        {
            before: function (args) {
                // load model
                return loadRecordForUpdate(controller, args)
            },

            input: input,
            method: function (args) {
                // perform update
                return update(controller, args)
            },
            methodName: 'update',
            role: role,
            template: 'instance',
        },
    ]
}
124197
function UserMethods(models) {
      this.models = models;
      this.removeEmail = bind(this.removeEmail, this);
      this.addEmail = bind(this.addEmail, this);
      this.resetPasswordToken = bind(this.resetPasswordToken, this);
      this.resetPassword = bind(this.resetPassword, this);
      this.removeRoles = bind(this.removeRoles, this);
      this.addRoles = bind(this.addRoles, this);
      this.removeIdentityFromUser = bind(this.removeIdentityFromUser, this);
      this.addIdentityToUser = bind(this.addIdentityToUser, this);
      this._profileImageFromProfile = bind(this._profileImageFromProfile, this);
      this._displayNameFromProfile = bind(this._displayNameFromProfile, this);
      this._usernameFromProfile = bind(this._usernameFromProfile, this);
      this.getOrCreateUserFromProvider = bind(this.getOrCreateUserFromProvider, this);
      this.create = bind(this.create, this);
      this._hashPassword = bind(this._hashPassword, this);
      this.validateUserByUsernameOrEmail = bind(this.validateUserByUsernameOrEmail, this);
      this.findUserByUsernameOrEmail = bind(this.findUserByUsernameOrEmail, this);
      this.setPassword = bind(this.setPassword, this);
      this.destroy = bind(this.destroy, this);
      this["delete"] = bind(this["delete"], this);
      this.patch = bind(this.patch, this);
      this.getByNameOrId = bind(this.getByNameOrId, this);
      this.getByPrimaryEmail = bind(this.getByPrimaryEmail, this);
      this.getByName = bind(this.getByName, this);
      this.lookup = bind(this.lookup, this);
      this.getByUsernames = bind(this.getByUsernames, this);
      this.getByIds = bind(this.getByIds, this);
      this.get = bind(this.get, this);
      this.all = bind(this.all, this);
      Hoek.assert(this.models, i18n.assertModelsRequired);
      Hoek.assert(this.models.User, i18n.assertUserInModelsRequired);
    }
495514
function listClassMethods (Model) {
  var classMethods = Object.keys(Model.schema.statics);
  for (var method in Model) {
    if (!isPrivateMethod(method) && isFunction(Model[method])) {
      classMethods.push(method);
    }
  }
  return classMethods;
}
745858
function(model, options) {
      this._byId[model.cid] = model;
      if (model.id != null) this._byId[model.id] = model;
      if (!model.collection) model.collection = this;
      model.on('all', this._onModelEvent, this);
    }
350610
function initModels (config) {
    // iterate over models
    return Promise.each(_.values(config.models), model => {
        // if model does not have a mysql client then add from app config
        if (model.mysqlClient === null) {
            // get mysql client for model
            var mysql = config.mysql[model.name] || config.mysql.default
            // require database
            assert.ok(mysql, 'mysql client not found for model '+model.name)
            // set database for model
            model.mysql(mysql)
        }
        // if model does not have redis add
        if (!defined(model.cache)) {
            // get redis client for model
            var redis = config.redis[model.name] || config.redis.default
            // redis is optional
            if (defined(redis)) {
                model.redis(redis)
            }
        }
        // sync model unless NO_SYNC env flag set
        if (!process.env.NO_SYNC) {
            return model.sync()
        }
    })
}
952317
function _initCollections() {
    if (!this._collections) {
      return;
    }

    for (var coll in this._collections) {
      this[coll] = new this._collections[coll](null, { parent: this, parse: true });
    }
  }
1058586
function setDefaultMethods(modelObj) {
    /* This will attach the .data(key, _val) method, that works as a virtual getter/setter.*/
    const dataKey = Symbol("data");
    modelObj.method(function data(key, _val) {
      if (typeof this[dataKey] === 'undefined') this[dataKey] = {};
      if (typeof key !== 'string' || !key) return null;
      if (typeof _val === 'undefined') return (typeof this[dataKey][key] === 'undefined' ? null : this[dataKey][key]);
      this[dataKey][key] = _val;
      return this;
    });
  }