express-sweet
Advanced tools
Changelog
[1.0.13] - 2021/12/13
let transaction;
try {
transaction = await BookModel.begin({
isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
type: BookModel.Transaction.TYPES.DEFERRED,
});
const book = await BookModel.findOne({where: {id: 1}}, {transaction});
book.title = 'When Im Gone';
await book.save({transaction});
await transaction.commit();
// Load updated data.
await book.reload();
} catch (error) {
if (transaction)
await transaction.rollback();
}
Changelog
[1.0.12] - 2021/11/16
// By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
// Note that since this is a raw query, the metadata are dialect specific.
const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
// In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
// We didn't need to destructure the result here - the results were returned directly
const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
Changelog
[1.0.11] - 2021/11/10
Changelog
[1.0.10] - 2021/10/19
Changelog
[1.0.8] - 2021/9/25
Changelog
[1.0.7] - 2021/8/13
Changelog
[1.0.6] - 2021/8/13
Changelog
[1.0.5] - 2021/8/12
Changelog
[1.0.4] - 2021/6/13