KNEX/Node, raw SQL

KNEX/Node, raw SQL

rldean1rldean1 Posts: 126Questions: 58Answers: 1

I'm reading the docs, and it says that .where() is available, and I've successfully used it!

I tried to chain some of the other KNEX mehtods, like .orderBy(), but that is not available on the editor instance.

It is, however, available when chained onto db .... db.orderBy().

Can I execute raw SQL into something that Editor can handle? In the PHP examples, it looks like you can, but how do I do that in NODE/KNEX?

let editor = new Editor(db, 'OnboardingAppointments', 'ProcessingID')
    .readTable('vueOA_Admin_Attendance')
    .fields(...)
    .where(
        {'StartDate': targetDate}
    );

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 52,636Questions: 1Answers: 8,053 Site admin
    Answer ✓

    Use the Editor.where() method with a function to get access to the Knex object - e.g.:

    .where(q => {
      q.where({'StartDate': targetDate});
    })
    

    More documentation on that available here.

    Allan

Sign In or Register to comment.