Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

egg-sequelize-autotrx

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-sequelize-autotrx - npm Package Compare versions

Comparing version 0.0.15 to 0.0.16

18

app/middleware/transaction.js
module.exports = (options, app) => async (ctx, next) => {
const { namespace } = app.config.sequelizeAutotrx
const sequelizeConfig = app.config.sequelize

@@ -8,7 +7,7 @@

sequelizeConfig.datasources.forEach(datasource => {
inject(ctx, getDelegate(datasource), namespace)
inject(ctx, getDelegate(datasource))
})
} else { // single datasource
app.loggers.coreLogger.info(`[egg-sequelize-autotrx] single database case`)
inject(ctx, getDelegate(sequelizeConfig), namespace)
inject(ctx, getDelegate(sequelizeConfig))
}

@@ -22,13 +21,14 @@

const inject = (ctx, delegate, namespace) => {
const inject = (ctx, delegate) => {
const { app } = ctx
const model = ctx[delegate]
const { app } = ctx
console.log('------', model.constructor)
console.log('------ _cls', model.constructor._cls)
// https://github.com/sequelize/sequelize/blob/master/lib/sequelize.js#L1044
// namespace has to get from _cls, otherwise it will have issue for multiple datasources case
const namespace = model.constructor._cls
if (!model.transaction.__injected) {
const oldTrx = model.transaction
model.transaction = async task => {
let transaction = namespace.get('transaction')
const transaction = namespace.get('transaction')
if (transaction) {

@@ -35,0 +35,0 @@ app.loggers.coreLogger.info(`[egg-sequelize-autotrx] ctx.[${delegate}].transaction call injected transaction method`)

{
"name": "egg-sequelize-autotrx",
"version": "0.0.15",
"version": "0.0.16",
"description": "Auto transaction based on cls-hooked for egg-sequelize plugin",

@@ -5,0 +5,0 @@ "eggPlugin": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc