Ejemplo n.º 1
0
    def delete_collection_items(self):
        coll = self.reference.get_collection()

        qs = QuerySet(coll)
        q = qs.get_query(self.api_arguments, self.objects)
        for f in self.additional_filters:
            q = q.filter(f)

        print("Delete collection items")
        print(q)
        if not self.delete_all and not qs.is_restricted(self.api_arguments, self.objects):
            raise PermissionError("Cannot delete all collection items without a specific request.")

        print([x for x in q.run(coll.application.connection)])
        return q.delete(durability=self.durability, return_changes=self.return_changes).run(coll.application.connection)
Ejemplo n.º 2
0
    def get_collection_items(self):
        coll = self.reference.get_collection()
        if self.reference.format in {'schema', 'help'}:
            return coll

        qs = QuerySet(coll)
        q = qs.get_query(self.api_arguments, self.objects)
        for f in self.additional_filters:
            q = q.filter(f)

        if qs.use_raw_results:
            results = q.run(coll.application.connection)
            try:
                return [x for x in results]
            except:
                return {"_": results}
        else:
            return [x for x in coll.q(q)]
Ejemplo n.º 3
0
    def get_collection_items(self):
        coll = self.reference.get_collection()
        if self.reference.format in {"schema", "help"}:
            return coll

        qs = QuerySet(coll)
        q = qs.get_query(self.api_arguments, self.objects)
        for f in self.additional_filters:
            q = q.filter(f)

        if qs.use_raw_results:
            results = q.run(coll.application.connection)
            try:
                return [x for x in results]
            except:
                return {"_": results}
        else:
            return [x for x in coll.q(q)]
Ejemplo n.º 4
0
    def delete_collection_items(self):
        coll = self.reference.get_collection()

        qs = QuerySet(coll)
        q = qs.get_query(self.api_arguments, self.objects)
        for f in self.additional_filters:
            q = q.filter(f)

        print("Delete collection items")
        print(q)
        if not self.delete_all and not qs.is_restricted(
                self.api_arguments, self.objects):
            raise PermissionError(
                "Cannot delete all collection items without a specific request."
            )

        print([x for x in q.run(coll.application.connection)])
        return q.delete(durability=self.durability,
                        return_changes=self.return_changes).run(
                            coll.application.connection)