0

In MySQL Workbench I have this:

USE my_db;
SELECT 
    transactions.created_at, price
FROM
    transactions
        JOIN
    transactions_items ON transactions.id = transactions_items.transaction_id
        JOIN
    store_items ON store_items.id = transactions_items.store_item_id;

As a result in workbench I get created_at: price. How can I create request to DB using knex syntax to get object {created_at: price}?

I was trying to use knex.raw(), but it does not seem to be working.

1 Answer 1

2
const response = await knex('transactions')
        .join('transactions_items', 'transactions.id', '=', 'transactions_items.transaction_id')
        .join('store_items', 'store_items.id', '=', 'transactions_items.store_item_id')
        .select('transactions.created_at', 'price')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.