Find a model from the store by resource id
555667
def find(model, rid):
    

    validate_rid(model, rid)

    rid_field = model.rid_field
    model = goldman.sess.store.find(model.RTYPE, rid_field, rid)

    if not model:
        abort(exceptions.DocumentNotFound)

    return model
1321485
def locally(self):
        

        from .backends import python
        from . import models

        store = python.IterableStore(values=self)
        return store.query(self.manager.model).all()
933907
def get(self, id):
        
        for obj in self.model.db:
            if obj["id"] == id:
                return self._cast_model(obj)

        return None
1240486
def lookup_model_by_kind(kind):
    
    model = _known_models.get(kind)
    if model is None:
        raise RuntimeError(f"Model for kind {kind!r} not found.")
    return model
477841
def get(self, id, **options):
        ''''''
        if not self._item_path:
            raise AttributeError('get is not available for %s' % self._item_name)
        target = self._item_path % id
        json_data = self._redmine.get(target, **options)
        data = self._redmine.unwrap_json(self._item_type, json_data)
        data['_source_path'] = target
        return self._objectify(data=data)
722915
function getResource(storeName, item) {
		var res,
			view = this,
			store = $views[storeName];

		res = store && store[item];
		while ((res === undefined) && view) {
			store = view.tmpl[storeName];
			res = store && store[item];
			view = view.parent;
		}
		return res;
	}
1274421
def load(self):
        

        if self.rid and not self.is_loaded:
            store = goldman.sess.store
            self._is_loaded = True

            self.model = store.find(self.rtype, self.field, self.rid)

        return self.model
32928
def find(self, id):
        
        url = "{}/{}/{}".format(__endpoint__, self.type.RESOURCE, id)
        response = RestClient.get(url)[self.type.RESOURCE[:-1]]
        return self.type(response)
526241
protected function findModel($id)
    {
        /* @var $modelClass ActiveRecord */
        $modelClass = $this->modelClass;
        $keys = $modelClass::primaryKey();
        if (count($keys) > 1) {
            $values = explode(',', $id);
            if (count($keys) === count($values)) {
                $model = $modelClass::findOne(array_combine($keys, $values));
            }
        } elseif ($id !== null) {
            $model = $modelClass::findOne($id);
        }

        if (isset($model)) {
            return $model;
        } else {
            throw new NotFoundHttpException("Object not found: '$id'");
        }
    }
344736
function findRecordIds(store, rowData) {

      var internalIds = [];

      store.each(function (m) {
        for (var i = 0; i < rowData.length; i++) {
          var item = rowData[i];
          var dataIndex = item[0];
          var value = item[1];
          var fieldValue = m.get(dataIndex);
          if (fieldValue !== value) {
            return true; // To next record.
          }
        }
        internalIds.push(m.internalId);
        return true;
      });

      if (!internalIds.length) {
        throw new Error('Record not found for ' + JSON.stringify(rowData));
      }

      return internalIds;
    }
737327
public static <ID, T extends Model> Finder<ID, T> withFinder() {
        return withFinder(DataSourceManager.getDefaultDataSourceName());
    }
174001
protected function findModel($id)
    {
        if (($model = TermOfProductType::findOne($id)) !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException(t('app', 'The requested page does not exist.'));
        }
    }
184002
def get_instance(model, instance_id):
    
    try:
        model = get_model(model)
    except ImportError:
        return None

    return model.query.get(instance_id)
205281
def _find_models(self, constructor, table_name, constraints=None, *, columns=None,
                   order_by=None, limiting=None):
    """"""
    for record in self.find_all(table_name, constraints, columns=columns, order_by=order_by,
                                limiting=limiting):
      yield constructor(record)
36472
def get_resource_by_id(resource_id, api_version, extract_value=None):
    '''
    
    '''
    ret = {}

    try:
        resconn = get_conn(client_type='resource')
        resource_query = resconn.resources.get_by_id(
            resource_id=resource_id,
            api_version=api_version
        )
        resource_dict = resource_query.as_dict()
        if extract_value is not None:
            ret = resource_dict[extract_value]
        else:
            ret = resource_dict
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('resource', exc.message)
        ret = {'Error': exc.message}

    return ret
32532
def find_by_id id, prefixed = false
      # Build a prefixed id if expected
      id = prefixed_id(id) if prefixed
      log_info "find_by_id (#{id}, #{prefixed}) > #{id}"

      # Search in jobs queues
      @jobs.find { |item| item.id == id }
    end
1248941
def find_record(relation = nil)
      if locate_id.nil? || (locate_id.is_a?(::Numeric) && locate_id == 0) || (locate_id.to_s == '')
        return -1
      end

      dataset = load_records(relation, false)
      return -1 if dataset.blank?

      first_item = dataset.first
      klass = first_item.class

      id_field = klass.respond_to?('primary_key')       ? klass.primary_key   : nil
      id_field ||= first_item.respond_to?('id')         ? 'id'                : nil

      return -1 unless id_field
      if locate_id.is_a?(::Numeric)
        dataset.index{|item| item.send(id_field) == locate_id} || -1
      else
        loc_id = locate_id.to_s.downcase
        dataset.index{|item| item.send(id_field).to_s.downcase == loc_id} || -1
      end

    end