Returns a function that knows how to prepare data from `findAll` or `findOne` calls. `name` should be either `model` or `models`.
430258
function(name) {
            var parseName = "parse" + can.capitalize(name);
            return function(data) {
                // If there's a `parse...` function, use its output.
                if (this[parseName]) {
                    data = this[parseName].apply(this, arguments);
                }
                // Run our maybe-parsed data through `model` or `models`.
                return this[name](data);
            };
        }
539407
def find(cls, name):
        ''''''
        if not cls.mapping:  # pragma: no branch
            for _, obj in inspect.getmembers(exceptions):
                if inspect.isclass(obj):
                    if issubclass(obj, exceptions.NSQException):  # pragma: no branch
                        if hasattr(obj, 'name'):
                            cls.mapping[obj.name] = obj
        klass = cls.mapping.get(name)
        if klass == None:
            raise TypeError('No matching exception for %s' % name)
        return klass
1207925
function prepOne(modelName, definition)
	{
		definition = _.clone(definition);

		// inherit options from defineOptions (except fields and through-related options)
		var fields = definition.fields = _.clone(definition.fields || {}),
			options = definition.options = _.clone(definition.options || {});

		utils.defaultsNoUndef(options, defineOptions);
		['fields', 'associateThrough', 'skipFieldsOnThrough', 'camelThrough'].forEach(function(fieldName) {
			delete options[fieldName];
		});

		if (options.primaryKeyType) {
			options.primaryKeyAttributes.type = options.primaryKeyType;
			delete options.primaryKeyType;
		}

		options.primaryKeyAttributes = _.defaults({
			primaryKey: true,
			_autoGenerated: true
		}, options.primaryKeyAttributes, defineOptions.primaryKeyAttributes, {
			allowNull: false
		});

		if ([Sequelize.INTEGER.key, Sequelize.BIGINT.key].indexOf(options.primaryKeyAttributes.type.key) != -1) options.primaryKeyAttributes.autoIncrement = true;
		if (options.primaryKeyAttributes.type.key == Sequelize.UUID.key && !options.primaryKeyAttributes.defaultValue) options.primaryKeyAttributes.defaultValue = Sequelize.UUIDV4;

		// add additional fields
		if (defineOptions.fields && !options.skipFields) {
			_.forIn(defineOptions.fields, function(field, fieldName) {
				if (fields[fieldName] !== undefined) return;
				field = utils.functionValue(field, modelName, definition, definitions);
				if (field instanceof Sequelize.ABSTRACT) field = {type: field};
				fields[fieldName] = _.clone(field);
			});
		}

		// delete empty fields and set field type where shorthand definition used
		_.forIn(fields, function(field, fieldName) {
			if (!field) {
				delete fields[fieldName];
			} else if (!_.isPlainObject(field)) {
				fields[fieldName] = {type: field};
			}
		});

		// find primary key
		var key;
		_.forIn(fields, function(field, fieldName) {
			if (field.primaryKey) {
				key = fieldName;
				return false;
			}
		});

		// if no primary key, create primary key column
		if (!key) {
			if (!options.primaryKey) throw new Sequelize.DefinerError("Model '" + modelName + "' has no primary key defined");

			key = utils.functionValue(options.primaryKey, modelName, definition, definitions);

			if (options.primaryKeyFirst) {
				utils.unshift(fields, key, options.primaryKeyAttributes);
			} else {
				fields[key] = options.primaryKeyAttributes;
			}
		}

		definition.primaryKey = key;
		primaryKeys[modelName + Utils.uppercaseFirst(key)] = primaryKeys[modelName + '_' + key] = {model: modelName, field: key};

		// get table name
		utils.defaultNoUndef(options, 'tableName', options.freezeTableName ? modelName : patches.underscoredIf(Utils.pluralize(modelName), options.underscoredAll));

		// return definition
		return definition;
	}
1192870
def load_model_from_link(name, **overrides):
    """"""
    path = get_data_path() / name / "__init__.py"
    try:
        cls = import_file(name, path)
    except AttributeError:
        raise IOError(Errors.E051.format(name=name))
    return cls.load(**overrides)
193276
def compiled_model(self):
        """"""
        return ALCHEMY_TEMPLATES.model.safe_substitute(class_name=self.class_name,
                                                       table_name=self.table_name,
                                                       column_definitions=self.compiled_columns,
                                                       init_function=self.compiled_init_func,
                                                       update_function=self.compiled_update_func,
                                                       hash_function=self.compiled_hash_func,
                                                       eq_function=self.compiled_eq_func,
                                                       neq_function=self.compiled_neq_func,
                                                       str_function=self.compiled_str_func,
                                                       unicode_function=self.compiled_unicode_func,
                                                       repr_function=self.compiled_repr_func,
                                                       types=", ".join(self.basic_types),
                                                       username=self.username,
                                                       foreign_keys=self.compiled_foreign_keys,
                                                       relationships=self.compiled_relationships,
                                                       named_imports=self.compiled_named_imports,
                                                       orm_imports=self.compiled_orm_imports,
                                                       get_proxy_cls_function=self.compiled_proxy_cls_func,
                                                       add_function=ALCHEMY_TEMPLATES.add_function.template,
                                                       delete_function=ALCHEMY_TEMPLATES.delete_function.template,
                                                       to_dict_function=ALCHEMY_TEMPLATES.to_dict_function.template,
                                                       to_proxy_function=ALCHEMY_TEMPLATES.to_proxy_function.template,
                                                       from_proxy_function=ALCHEMY_TEMPLATES.from_proxy_function.template)
774769
function modelExport(m) {
  const result = _.mapValues(m.classes, _.head)
  result[m.__name] = m
  return result
}
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;
  }
1015802
def named_function(name):
    """"""
    name_parts = name.split('.')
    module = named_object('.'.join(name_parts[:-1]))
    func = getattr(module, name_parts[-1])
    if hasattr(func, 'original_func'):
        func = func.original_func
    return func
1041787
def get_model(method):
    """"""

    @wraps(method)
    def wrapper(migrator, model, *args, **kwargs):
        if isinstance(model, str):
            return method(migrator, migrator.orm[model], *args, **kwargs)
        return method(migrator, model, *args, **kwargs)
    return wrapper
1325467
def _find_model(self, constructor, table_name, constraints=None, *, columns=None, order_by=None):
    """"""
    data = self.find(table_name, constraints, columns=columns, order_by=order_by)
    return constructor(data) if data else None
988859
def model(self, name=None, model=None, mask=None, **kwargs):
        
        if isinstance(model, (flask_marshmallow.Schema, flask_marshmallow.base_fields.FieldABC)):
            if not name:
                name = model.__class__.__name__
            api_model = Model(name, model, mask=mask)
            api_model.__apidoc__ = kwargs
            return self.add_model(name, api_model)
        return super(Namespace, self).model(name=name, model=model, **kwargs)
1111898
function( name, callback ) {
		var f = { name: name, callback: callback };

		// Type checking
		if ( ! munit.isString( name ) || ! name.length ) {
			throw new Error( "Name not found for formatter" );
		}
		else if ( ! munit.isFunction( callback ) ) {
			throw new Error( "Callback not found for formatter" );
		}
		else if ( render._formatHash[ name ] ) {
			throw new Error( "Format '" + name + "' already exists" );
		}

		// Store info
		render._formats.push( f );
		render._formatHash[ name ] = f;
	}
959548
function Model (name, schema, options) {
  if (typeof(name) != "string") throw "model name must be provided and a string";
  if (arguments.length==1) { options = {}; schema = {} };
  if (arguments.length==2) { options = schema; schema = {} };

  var self = function Document(raw) { return document.Document.call(this, self, raw) }; // Call the Document builder
  _.extend(self, Model.prototype); // Ugly but works - we need to return a function but still inherit prototype
  var emitter = new events.EventEmitter();
  emitter.setMaxListeners(0);
  for (var prop in emitter) self[prop] = emitter[prop];

  self.modelName = name;
  self.schema = schemas.normalize(Object.assign({}, schema)); // Normalize to allow for short-hands
  self.filename = path.normalize(options.filename || path.join(Model.dbPath || ".", name+".db"));
  self.options  = _.extend({}, Model.defaults, options);

  // Indexed by field name, dot notation can be used
  // _id is always indexed and since _ids are generated randomly the underlying
  // binary is always well-balanced
  self.indexes = {};
  self.indexes._id = new Index({ fieldName: '_id', unique: true });
  schemas.indexes(schema).forEach(function(idx) { self.ensureIndex(idx) });

  // Concurrency control for 1) index building and 2) pulling objects from LevelUP
  self._pipe = new bagpipe(1);
  self._pipe.pause();
  self._retrQueue = new bagpipe(LEVELUP_RETR_CONCURRENCY);
  self._retrQueue._locked = {}; self._retrQueue._locks = {}; // Hide those in ._retrQueue
  self._methods = {};

  if (self.options.autoLoad) self.initStore();

  return self;
}
1011039
function (req, res) {
        {modelName}.find(function (err, {pluralName}) {
            if (err) {
                return res.status(500).json({
                    message: 'Error when getting {name}.',
                    error: err
                });
            }
            return res.json({pluralName});
        });
    }
1222438
def get_field_model(name, model=None):
    
    if '.' in name:
        m, name = name.split('.')
        model = get_model(m)

    if model:
        return getattr(model, name, None), model
    else:
        return None, None
361438
function(model, options) {
            options || (options = {});
            if (!(model instanceof Model)) {
                var attrs = model;
                options.collection = this;
                model = new this.model(options, attrs);
            } else if (!model.collection) {
                model.collection = this;
            }
            return model;
        }
479626
def get_model(name):
    

    model = MODELS.get(name.lower(), None)

    assert model, "Could not locate model by name '%s'" % name

    return model