How to use the awokado.filter_parser.FilterItem.create function in awokado

To help you get started, we’ve selected a few awokado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 5783354 / awokado / awokado / resource.py View on Github external
"""
        self._check_model_exists()

        data = payload[self.Meta.name]

        data_to_update = self._to_update(data)

        ids = get_ids_from_payload(self.Meta.model, data_to_update)

        session.bulk_update_mappings(self.Meta.model, data_to_update)
        self._save_m2m(session, data, update=True)

        result = self.read_handler(
            session=session,
            user_id=user_id,
            filters=[FilterItem.create("id", OP_IN, ids)],
        )

        return result
github 5783354 / awokado / awokado / resource.py View on Github external
data_to_insert = [self._to_create(i) for i in data]

        # insert to DB
        resource_ids = bulky.insert(
            session,
            self.Meta.model,
            data_to_insert,
            returning=[self.Meta.model.id],
        )
        ids = [r.id for r in resource_ids]

        result = self.read_handler(
            session=session,
            user_id=user_id,
            filters=[FilterItem.create("id", OP_IN, ids)],
        )

        return result