KNEX/Node, raw SQL

KNEX/Node, raw SQL

rldean1rldean1 Posts: 141Questions: 66Answers: 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: 63,498Questions: 1Answers: 10,471 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

This discussion has been closed.