Created
June 27, 2018 09:00
-
-
Save thetutlage/2cd05b8969fb2b119cc6fcf26c5c3849 to your computer and use it in GitHub Desktop.
Adonis database insert queries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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