Created
June 23, 2020 10:28
-
-
Save velotiotech/ce11cb75fb628e562efc4a0fd35549a6 to your computer and use it in GitHub Desktop.
This file contains 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
const personWithPets = { | |
firstName: 'Matt', | |
lastName: 'Damon', | |
age: 43, | |
pets: [ | |
{ | |
name: 'Doggo', | |
species: 'dog' | |
}, | |
{ | |
name: 'Kat', | |
species: 'cat' | |
} | |
] | |
}; | |
// wrap `insertGraph` call in a transaction since its creating multiple queries. | |
const insertedGraph = await transaction(Person.knex(), trx => { | |
return ( | |
Person.query(trx).insertGraph(personWithPets) | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment