Transactions
alvaropaco opened this issue · 4 comments
alvaropaco commented
I couldn't create a transaction with this sequelize instance. How can i use sequelize transactions with sails-hook-sequelize?
malpercio commented
You have sequelize
as a global variable and a CLS already configured
sequelize.transaction((t1) => {
//Something
})
.then()
.catch()
KSDaemon commented
Hi @alvaro-paco! @malpercio had given answer. So, closing for now. Feel free to reopen if you face any problems
jhnferraris commented
Is this still work on Sails 1.0? I'm getting transaction is not a function
.
sails> sequelize.transaction()
TypeError: sequelize.transaction is not a function
This is the output when I try to run it on sails console
Thanks for the help.
jhnferraris commented
If anyone of you is using SailsJS 1.0, this is what I did
SequelizeConnections.default.transaction(transaction => {
// Your transaction
})
assuming that default
is the key in your sails.config.datastores
datastores: {
default: {
adapter: require("sails-postgresql"),
database: "your_db",
user: "your_user",
password: "<your_password>",
ssl: false,
options: {
dialect: "postgres",
host: "<localhost>",
port: 5432,
logging: console.log,
}
}
},