Skip to content

Feature Request: A tutorial of custom Operations (to do a sophisticated insert operation) #2106

@laurisvan

Description

@laurisvan

Related to my earlier #2096 ticket of optimising whereIn queries. Thanks to the support of overriding methods, we could speed up queries drastically.

Now we would like to eliminate thousands of parameters in batch insert. I envision this could be done in form of
INSERT INTO <TABLE> (<COLS>) VALUES (<VALUES>) where VALUES would support raw expression (I would pass JSON string that would be decoded with postgres function).

Now I understand insert is implemented with KnexOperation that extends ObjectionToKnexConvertingOperation, and knex insert itself does not seem to support specifying cols or values part, either. I believe that might be a bit difficult to support in Objection?

How could I override insert with a custom operation with signature compatible with KnexOperation, but the practical implementation would be something in line with knex.raw()? E.g. what is the minimal implementation of a custom Operation that could execute a custom query?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions