Skip to content

v0.2.0

Choose a tag to compare

@schickling schickling released this 22 Nov 12:49
· 3365 commits to main since this release
669b49b

Core

  • Added query builder API

    const table = DbSchema.table('myTable', {
      id: DbSchema.text({ primaryKey: true }),
      name: DbSchema.text(),
    })
    
    table.query.select('name')
    table.query.where('name', '==', 'Alice')
    table.query.where({ name: 'Alice' })
    table.query.orderBy('name', 'desc').offset(10).limit(10)
    table.query.count().where('name', 'like', '%Ali%')
    table.query.row('123', { insertValues: { name: 'Bob' } })
  • Breaking: Renamed querySQL to queryDb and adjusted the signature to allow both the new query builder API and raw SQL queries:

     // before
     const query$ = querySQL(sql`select * from myTable where name = 'Alice'`, {
      schema: Schema.Array(table.schema),
    })
    
    // after (raw SQL)
     const query$ = queryDb({
      query: sql`select * from myTable where name = 'Alice'`,
      schema: Schema.Array(table.schema),
    })
    
    // or with the query builder API
    const query$ = queryDb(table.query.select('name').where({ name: 'Alice' }))
  • Breaking: Replaced rowQuery() with table.query.row() (as part of the new query builder API)

React integration

  • Fix: useRow now type-safe for non-nullable/non-default columns. Renamed options.defaultValues to options.insertValues

Misc

  • Removed Drizzle example in favour of new query builder API
  • Removed livestore/examples repository in favour of /examples/standalone (additionally /examples/src for maintainers)