Returns one document dict if one passes the filter.
        Returns None otherwise.
501860
def find_one(cls, filter=None, *args, **kwargs):
        
        return cls.collection.find_one(filter, *args, **kwargs)
755008
def get_document(self, document_id):
        
        key = 'doc.%s.%s' % (self.name, decode(document_id))
        return decode_dict(self.db.hgetall(key))
783022
def get_filter_rule(self, _filter, way='in'):
        
        if isinstance(_filter, zobjects.FilterRule):
            _filter = _filter.name
        for f in self.get_filter_rules(way=way):
            if f.name == _filter:
                return f
        return None
887589
def get_filters(self):
        
        if self._filters:
            filters_list = self._filters
            if isinstance(filters_list[-1], Enum):
                filters_list = filters_list[:-1]
            return ' '.join(
                [fs.value if isinstance(fs, Enum) else fs[1] for fs in
                 filters_list]).strip()
        else:
            return None
554687
def get_document_field(instance):
        
        for name, field in instance.searchindex.fields.items():
            if field.document is True:
                return name
1076751
def getMetadata(self, objectId=None, **filters):
        
        filters.update({"urn": objectId})
        return self.getCapabilities(**filters)
725553
def find_one(self, collection, selector={}):
        """"""
        for _id, doc in self.collection_data.data.get(collection, {}).items():
            doc.update({'_id': _id})
            if selector == {}:
                return doc
            for key, value in selector.items():
                if key in doc and doc[key] == value:
                    return doc
        return None
563918
def _wrapper_find_one(self, filter_=None, *args, **kwargs):
        
        return self.__collect.find_one(filter_, *args, **kwargs)
1349301
def get_document_list(self):
        
        try:
            return self.__dict__['document_list']
        except KeyError:
            obj_list = DocumentSet([
                self._connection.documents.get(i) for i in self.document_ids
            ])
            self.__dict__['document_list'] = obj_list
            return obj_list
931016
def read(self):
        
        cursor = self.get_collection().find(
            {
                '_id': {'$in': self._document_ids},
                self._field: {'$exists': True}
            },
            {self._field: True}
        )

        return {doc['_id']: doc[self._field] for doc in cursor}
780640
def get_one(self, object_id):
        
        return self.session.query(self.cls).filter_by(id=object_id).one()
56539
def filter(self):
        
        if isinstance(self._filter, str):
            return self._decode_query(self._filter)
        return self._filter
1038912
def _get_filter_ids(cls, request):
        
        id_query = request.url.query.get('id', None)

        if id_query is None:
            return None

        filter_ids = id_query.split(',')
        for filter_id in filter_ids:
            cls._validate_id(filter_id)

        return filter_ids
4685
def one(cls, filter=None, **kwargs):
        """"""
        from mongoframes.queries import Condition, Group, to_refs

        # Flatten the projection
        kwargs['projection'], references, subs = \
                cls._flatten_projection(
                    kwargs.get('projection', cls._default_projection)
                    )

        # Find the document
        if isinstance(filter, (Condition, Group)):
            filter = filter.to_dict()

        document = cls.get_collection().find_one(to_refs(filter), **kwargs)

        # Make sure we found a document
        if not document:
            return

        # Dereference the document (if required)
        if references:
            cls._dereference([document], references)

        # Add sub-frames to the document (if required)
        if subs:
            cls._apply_sub_frames([document], subs)

        return cls(document)
397425
def dict_filter(d, exclude=[]):
    

    if isinstance(d, list):
        ret = []
        for e in d:
            ret.append(dict_filter(e, exclude))
        return ret
    elif isinstance(d, dict):
        ret = {}
        for k, v in d.items():
            if isinstance(k, builtin_str):
                k = str(k)

            assert isinstance(k, str)
            if k in exclude:
                continue
            ret[k] = dict_filter(v, exclude)
        return ret

    return d
1102234
def find_doc(self, name=None, ns_uri=None, first_only=False):
        
        return self.document.find(name=name, ns_uri=ns_uri,
            first_only=first_only)
498833
def get_last_doc(self):
        
        #search everything, sort by descending timestamp, return 1 row
        try:
            result = self.solr.search('*:*', sort='_ts desc', rows=1)
        except ValueError:
            return None

        for r in result:
            r['_id'] = r.pop(self.unique_key)
            return r