Skip to content

Advanced Query Builder #14

@maifeeulasad

Description

@maifeeulasad

String operations:

.where('name').startsWith('John')
.where('email').endsWith('@gmail.com')
.where('description').contains('important')
.where('name').matches(/^[A-Z]/)

Better range syntax:

.where('age').between(18, 65)  // More intuitive than range()
.where('price').notBetween(0, 10)

Array/Collection operations:

.where('tags').contains('typescript')
.where('skills').containsAny(['js', 'ts', 'node'])
.where('roles').containsAll(['admin', 'user'])
.where('id').in([1, 2, 3, 4])
.where('status').notIn(['deleted', 'archived'])

Logical operators:

.where('age').gte(18).or().where('hasParentalConsent').equals(true)
.where(qb => qb
  .where('type').equals('premium')
  .and('status').equals('active')
).or().where('isTrial').equals(true)

Aggregations:

await db.Order.query().sum('amount')
await db.Order.query().avg('price')
await db.Order.query().min('date')
await db.Order.query().max('date')
await db.Order.query().groupBy('status').count()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions