Select builds SELECT queries.
import Select from '@stackpress/inquire/Select';Most code uses it through engine.select(columns?).
const users = await engine.select<{ id: number; email: string }>([
'users.id',
'users.email'
])
.from('users')
.where('users.active = ?', [true])
.order('users.email')
.limit(10)
.offset(20);Set the source table.
Add a join.
const query = engine.select('*')
.from('users')
.join('inner', 'profiles', 'profiles.user_id', 'users.id');Set the row limit.
Set the row offset.
Add an ORDER BY clause. Default direction is ASC.
Replace the current selector list.
columns can be:
- a string
- a comma-separated string
- an array of strings or selector objects
Add a WHERE clause.
Add a JSON comparison filter.
Add a JSON containment filter.
Return the internal select state.
Return one QueryObject.
Execute the query through the attached engine.
When awaited, Select<R> resolves to R[].