Skip to content

Instantly share code, notes, and snippets.

@chris-muller
Created November 27, 2017 22:35
Show Gist options
  • Save chris-muller/f9717eae2f4d8aa5402ad02a730ea367 to your computer and use it in GitHub Desktop.
Save chris-muller/f9717eae2f4d8aa5402ad02a730ea367 to your computer and use it in GitHub Desktop.
Sequelize Insert With Association
// 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