0
Currently I have this query that returns all users:
async index({request}) {
const page = request.input('page')
const pageSize = request.input('pageSize')
const users = await User
.query()
.with('user')
.paginate(page, pageSize)
return users.toJSON()
}
I need to conditionally create a way to insert two Where if you have filter parameter.
For example, if you receive request.input('username')
add a clause where
:
.whereRaw('username = %?%', [request.input('username')])
I could not find in the documentation something that explained how to create conditionally where
. Could someone give me an example?
worked perfectly, obliged
– Betini O. Heleno