Skip to content

Instantly share code, notes, and snippets.

@thetutlage
Created June 27, 2018 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thetutlage/2cd05b8969fb2b119cc6fcf26c5c3849 to your computer and use it in GitHub Desktop.
Save thetutlage/2cd05b8969fb2b119cc6fcf26c5c3849 to your computer and use it in GitHub Desktop.
Adonis database insert queries
await Database
.table('users')
.insert({ username: 'virk', role: 'admin', password: 'secret' })
// Bulk inserts
await Database
.table('users')
.insert([
{ username: 'virk', role: 'admin', password: 'secret' },
{ username: 'nikk', role: 'guest', password: 'secret' }
])
// Updates
await Database
.table('users')
.where('username', 'virk')
.update({ role: 'owner' })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment