Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] - Add knex updateFrom method #2739

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jaketig
Copy link

@jaketig jaketig commented Jan 10, 2025

Adds updateFrom method from Knex

https://knexjs.org/guide/query-builder.html#updatefrom

Currently we cannot call .updateFrom on a model:

    myModel
      .query(trx)
      .with('a_cte', cteSubquery)
      .patch({
        ...
      })
      .updateFrom('a_cte')
      .whereRaw('my_table.id = a_cte.id');

Returns TypeError: myModel.query(...).with(...).patch(...).whereRaw(...).updateFrom is not a function

This works, but I would prefer to be able to call .updateFrom directly

    myModel
      .query(trx)
      .with('a_cte', cteSubquery)
      .patch({
        ...
      })
      .whereRaw('my_table.id = a_cte.id');
      .toKnexQuery()
      .updateFrom('a_cte');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant