Query.offset is not a function or query.where is not a function


#1

query.offset is not a function
hello,

offset not working.

my code is :

const query = await Database.table(‘users’)

if (requestData[‘length’] > 0) {
query.offset(0)
.limit(10)
}


#2

you put await on the first line, so that the query already made

try this:

const query = Database.table(‘users’)

if (requestData[‘length’] > 0) {
query.offset(0)
.limit(10)
}
const res = await query

#3

ohk it`s working, thanks


#4

can i use with like query.with(‘settings’). it`s posible?


#5

if you want to use .with()
you may use Lucid with .query()
ref: https://adonisjs.com/docs/4.1/relationships#_eagerloading

e.g.

const users = await User.query().with('settings').fetch()

#6

ok i got it , thanks for help.