Returns the list of documents found on the collection
181991
def list(self, request):
        
        pipeline = [{'$match': request.args.pop('match', {})}]

        sort = request.args.pop('sort', {})
        if sort:
            pipeline.append({'$sort': sort})

        project = request.args.pop('project', {})
        if project:
            pipeline.append({'$project': project})

        return Response(serialize(self.collection.aggregate(pipeline)))
306455
def __list_fields(cls):
        
        for name in cls._doc_type.mapping:
            field = cls._doc_type.mapping[name]
            yield name, field, False

        if hasattr(cls.__class__, '_index'):
            if not cls._index._mapping:
                return
            for name in cls._index._mapping:
                # don't return fields that are in _doc_type
                if name in cls._doc_type.mapping:
                    continue
                field = cls._index._mapping[name]
                yield name, field, True
812837
def get_record_collections(record, matcher):
    
    collections = current_collections.collections
    if collections is None:
        # build collections cache
        collections = current_collections.collections = dict(_build_cache())

    output = set()

    for collections in matcher(collections, record):
        output |= collections

    return list(output)
1181751
def findall(self, title=None):
        
        if title is None:
            return list(self)
        files = backend.iterfiles(self._drive, name=title)
        return [self[id] for id, _ in files]
1019150
def find_documents(self, sentence, limit=None, must_sort=True,
                       search_type='fuzzy'):
        
        sentence = sentence.strip()
        sentence = strip_accents(sentence)

        if sentence == u"":
            return self.get_all_docs()

        result_list_list = []
        total_results = 0

        for query_parser in self.search_param_list[search_type]:
            query = query_parser["query_parser"].parse(sentence)

            sortedby = None
            if must_sort and "sortedby" in query_parser:
                sortedby = query_parser['sortedby']
            if sortedby:
                results = self.__searcher.search(
                    query, limit=limit, sortedby=sortedby
                )
            else:
                results = self.__searcher.search(
                    query, limit=limit
                )
            results = [
                (result['docid'], result['doctype'])
                for result in results
            ]

            result_list_list.append(results)
            total_results += len(results)

            if not must_sort and total_results >= limit:
                break

        # merging results
        docs = set()
        for result_intermediate in result_list_list:
            for result in result_intermediate:
                doc = self._docs_by_id.get(result[0])
                if doc is None:
                    continue
                docs.add(doc)

        docs = [d for d in docs]

        if not must_sort and limit is not None:
            docs = docs[:limit]

        return docs
968695
def list_ext(self, collection, path, retrieve_all, **_params):
        """"""
        return self.list(collection, path, retrieve_all, **_params)
95895
def get_entities(self):
        
        try:
            return self.__dict__['entities']
        except KeyError:
            entities = self._connection.fetch(
                "documents/%s/entities.json" % self.id
            ).get("entities")
            obj_list = []
            for type, entity_list in list(entities.items()):
                for entity in entity_list:
                    entity['type'] = type
                    obj = Entity(entity)
                    obj_list.append(obj)
            self.__dict__['entities'] = obj_list
            return self.__dict__['entities']
26786
public function getVisitedCollections($document)
    {
        $oid = spl_object_hash($document);

        return isset($this->visitedCollections[$oid])
            ? $this->visitedCollections[$oid]
            : [];
    }
59923
def process_document(self, doc):
        

        descriptions = doc.select_segments("projects[*].description")
        projects = doc.select_segments("projects[*]")

        for d, p in zip(descriptions, projects):
            names = doc.extract(self.rule_extractor, d)
            p.store(names, "members")
        return list()
621744
def get_collections(self, pattern="*", libtype="*"):
        """"""

        sql = """SELECT collection.collection_id, collection.name, collection.doc,
                        collection.type, collection.path
                 FROM collection_table as collection
                 WHERE name like ?
                 AND type like ?
                 ORDER BY collection.name
              """

        cursor = self._execute(sql, (self._glob_to_sql(pattern),
                                     self._glob_to_sql(libtype)))
        sql_result = cursor.fetchall()

        return [{"collection_id": result[0],
                 "name": result[1],
                 "synopsis": result[2].split("\n")[0],
                 "type": result[3],
                 "path": result[4]
             } for result in sql_result]
270988
def count_documents(self, filter={},  *args, **kwargs):
        
        result = self.collection.count_documents(filter, *args, **kwargs)
        return result
571517
public List<com.cloudant.client.api.model.ReplicatorDocument> findAll() {
        List<ReplicatorDocument> couchDbReplicatorDocList = replicator.findAll();
        List<com.cloudant.client.api.model.ReplicatorDocument> replicatorDocList = new
                ArrayList<com.cloudant.client.api.model.ReplicatorDocument>();
        for (ReplicatorDocument couchDbReplicatorDoc : couchDbReplicatorDocList) {
            com.cloudant.client.api.model.ReplicatorDocument replicatorDoc = new com.cloudant
                    .client.api.model.ReplicatorDocument(couchDbReplicatorDoc);
            replicatorDocList.add(replicatorDoc);
        }
        return replicatorDocList;
    }
184599
def _list_collections(self, sock_info, slave_okay, session,
                          read_preference, **kwargs):
        """"""

        coll = self.get_collection(
            "$cmd", read_preference=read_preference)
        if sock_info.max_wire_version > 2:
            cmd = SON([("listCollections", 1),
                       ("cursor", {})])
            cmd.update(kwargs)
            with self.__client._tmp_session(
                    session, close=False) as tmp_session:
                cursor = self._command(
                    sock_info, cmd, slave_okay,
                    read_preference=read_preference,
                    session=tmp_session)["cursor"]
                return CommandCursor(
                    coll,
                    cursor,
                    sock_info.address,
                    session=tmp_session,
                    explicit_session=session is not None)
        else:
            match = _INDEX_REGEX
            if "filter" in kwargs:
                match = {"$and": [_INDEX_REGEX, kwargs["filter"]]}
            dblen = len(self.name.encode("utf8") + b".")
            pipeline = [
                {"$project": {"name": {"$substr": ["$name", dblen, -1]},
                              "options": 1}},
                {"$match": match}
            ]
            cmd = SON([("aggregate", "system.namespaces"),
                       ("pipeline", pipeline),
                       ("cursor", kwargs.get("cursor", {}))])
            cursor = self._command(sock_info, cmd, slave_okay)["cursor"]
            return CommandCursor(coll, cursor, sock_info.address)
817134
def collections(self):
        
        iterator = self._firestore_api.list_collection_ids(
            self._database_string, metadata=self._rpc_metadata
        )
        iterator.client = self
        iterator.item_to_value = _item_to_collection_ref
        return iterator
522249
def get_documents_in_database(self, with_id=True):
        
        documents = []
        for coll in self.get_collection_names():
            documents += self.get_documents_in_collection(
                coll,
                with_id=with_id
            )

        return documents
198911
def get_documents_count(self):
        
        db_collections = [
            self.database[c] for c in self.get_collection_names()
        ]  # list of all collections in database
        return sum([c.count() for c in db_collections])
935826
def find(cls, *args, **kwargs):
        
        return list(cls.collection.find(*args, **kwargs))