sequelize-delete-example/index.js

24 lines
572 B
JavaScript

const { user, article } = require('./models')
async function main() {
console.log(await user.findAll())
const author = await user.create({ name: 'author' })
const mod = await user.create({ name: 'moderator' })
const $article = await article.create({
title: 'Lorem Ipsum',
submittedBy: author.id,
reviewedBy: mod.id,
})
await author.destroy()
}
main()
.then(() => {
console.log('done')
process.exit(0)
})
.catch(error => {
console.error(`error: ${error}`)
process.exit(1)
})