I run 'npm install sequelize sqlite3' and 'yarn add sequelize sqlite3', my backend and front is running, but when i call my function this return an error "sequelize.transaction is not a function"
My function:
async sendorder(req, res){
try{
var sequelize = require('sequelize');
const t = await sequelize.transaction();
return res.ok({status: 200});
}catch(err){
return res.badRequest({err, status: 400})
}
}
if in console i run 'sequelize', this return sequelize class: http://dontpad.com/sequelizeClass
In order to use the Sequelize transaction you need to create a Sequelize instance using correct connection properties and then call transaction
for this instance:
var Sequelize = require('sequelize');
var sequelize = new Sequelize(connection_options)
const t = await sequelize.transaction();