import { eq, ne, gt, gte, lt, lte, inList, like, ilike, isNull, notNull, and, or, between } from 'remix/data-table'
// Object syntax (equality)
await db.query(users).where({ role: 'admin' }).all()
// Comparison operators
await db.query(orders).where(gt(orders.total, 100)).all()
await db.query(orders).where(gte(orders.total, 50)).all()
await db.query(orders).where(lt(orders.created_at, Date.now())).all()
// IN/NOT IN
await db.query(users).where(inList(users.id, ['u_1', 'u_2', 'u_3'])).all()
await db.query(orders).where(notInList(orders.status, ['cancelled', 'refunded'])).all()
// Pattern matching
await db.query(users).where(like(users.email, '%@example.com')).all()
await db.query(users).where(ilike(users.username, 'john%')).all() // case-insensitive
// Null checks
await db.query(users).where(isNull(users.deleted_at)).all()
await db.query(orders).where(notNull(orders.shipped_at)).all()
// Between
await db.query(orders).where(between(orders.total, 50, 500)).all()
// Logical operators
await db
.query(orders)
.where(
and(
gt(orders.total, 100),
inList(orders.status, ['pending', 'processing'])
)
)
.all()
await db
.query(users)
.where(
or(
eq(users.role, 'admin'),
eq(users.role, 'moderator')
)
)
.all()