0

I have a select statement:

const myObject = await MyObject 
.query()
.eager('foo')
.eager('foo.bar')
.omit(['some_big_data']) // Skip the giant field to improve performance/memory
.where('when_created', '>', '2019-09-01')
.whereNotNull('player_details')
.whereNull('region_id')
.limit(10000);

This results in the following SQL:

select `foo`.*
from `foo` 
where `when_created` > '2019-09-01'
and `player_details` is not null
and `region_id` is null
limit 1000;

I want to add the SQL use index (my_index) to the query, so it becomes:

select `foo`.*
from `foo` 
use index (my_index)
where `when_created` > '2019-09-01'
and `player_details` is not null
and `region_id` is null
limit 1000;

Is this possible to do in ObjectionJS, or do I need to drop to a raw query?

JimmyDix
  • 81
  • 4

1 Answers1

0

Knex 0.20 nor objection has any support for doing that. You need to write raw query to make it happen.

Mikael Lepistö
  • 18,909
  • 3
  • 68
  • 70