Created
November 27, 2017 22:35
-
-
Save chris-muller/f9717eae2f4d8aa5402ad02a730ea367 to your computer and use it in GitHub Desktop.
Sequelize Insert With Association
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
// Example of how to insert a record that includes a new association to be created with it | |
// assumes that sequelize and the associations have already been configured earlier. | |
var data = { | |
title: "Post title", | |
description: "Post description", | |
categories: [{ | |
title: "General", | |
description: "The default category." | |
}] | |
}; | |
const post = await models.post.create(data, {include: models.category}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment