PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

Help Wanted. Database query builder #110

Closed sjwalker189 closed 4 years ago

sjwalker189 commented 4 years ago

Heya, Is there the ability to use both models and a query builder? I cannot find anything in the docs

i.e. something like this would be perfect

const store = new Store({
  file: 'path/to/db.sqlite'
})

store.ready(async () => {
   const user = await store.table('users').where('id', 1).get()
})

Cheers

PhilWaldmann commented 4 years ago

openrecord uses knex for all SQL stores. To get your example working, you'll need to access the store.connection.

const store = new Store({
  file: 'path/to/db.sqlite'
})

store.ready(async () => {
   const user = await store.connection.table('users').where('id', 1).get()
})
sjwalker189 commented 4 years ago

Awesome, thanks for the help!