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

djorm

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djorm - npm Package Compare versions

Comparing version 0.1.7-alpha.2 to 0.1.7-alpha.5

db/__tests__/DatabaseHub.js

43

db/Database.js

@@ -9,2 +9,3 @@ const { DatabaseMapper } = require('./DatabaseMapper')

connecting = false
disconnectTimeout = null
Mapper = DatabaseMapper

@@ -22,2 +23,16 @@

planDisconnect () {
this.cancelDisconnectPlan()
this.disconnectTimeout = setTimeout(
() => this.disconnect(),
this.getProp('inactiveTimeout', 300)
)
}
cancelDisconnectPlan () {
if (this.disconnectTimeout) {
clearTimeout(this.disconnectTimeout)
}
}
async connectDb () {

@@ -28,7 +43,9 @@ throw new NotImplemented()

async connect () {
this.connecting = true
trace(`Connecting to ${this.props.driver} database`)
await this.connectDb()
this.connecting = false
debug(`Connected to ${this.props.driver} database`)
if (!this.connected) {
this.connecting = true
trace(`Connecting to ${this.props.driver} database`)
await this.connectDb()
this.connecting = false
debug(`Connected to ${this.props.driver} database`)
}
this.resolveQueue()

@@ -46,2 +63,10 @@ }

async disconnect () {
this.cancelDisconnectPlan()
if (this.connected) {
await this.disconnectDb()
debug(`Disconnected from ${this.props.driver} database`)
}
}
async disconnectDb () {
throw new NotImplemented()

@@ -65,3 +90,5 @@ }

debug(str)
return await this.queryDb(str)
const res = await this.queryDb(str)
this.planDisconnect()
return res
}

@@ -72,3 +99,5 @@

debug(str)
return await this.execDb(str)
const res = await this.execDb(str)
this.planDisconnect()
return res
}

@@ -75,0 +104,0 @@

2

db/index.js

@@ -5,3 +5,3 @@ module.exports = {

...require('./Count'),
...require('./DatabasePool'),
...require('./DatabaseHub'),
...require('./Delete'),

@@ -8,0 +8,0 @@ ...require('./Insert'),

@@ -5,9 +5,9 @@ class PropModel {

}
getProp (name, defaultValue) {
return this.props[name] || defaultValue
}
}
class ImmutablePropModel extends PropModel {
getProp (name) {
return this.props[name]
}
setProp (name, value, mutate = false) {

@@ -14,0 +14,0 @@ if (mutate) {

const init = async databases => {
const { Database } = require('../db/Database')
const { configDb } = require('../db/DatabasePool')
const { configDb } = require('../db/DatabaseHub')
Object.entries(databases).map(([dbName, dbConfig]) =>

@@ -10,6 +10,5 @@ configDb(Database.resolveDriver(dbConfig), dbName)

const shutdown = async () => {
const { disconnect } = require('../db/DatabasePool')
await disconnect()
await require('../db/DatabaseHub').disconnect()
}
module.exports = { init, shutdown }
const { DatabaseModelBase } = require('./DatabaseModelBase')
const { Delete } = require('../db/Delete')
const { ForeignKey } = require('../fields/ForeignKey')
const { getDb } = require('../db/DatabasePool')
const { getDb } = require('../db/DatabaseHub')
const { Insert } = require('../db/Insert')

@@ -6,0 +6,0 @@ const { ObjectManager } = require('./ObjectManager')

{
"name": "djorm",
"version": "0.1.7-alpha.2",
"version": "0.1.7-alpha.5",
"description": "Django like ORM framework",

@@ -38,3 +38,3 @@ "author": "Pavel Žák <pavel@zak.global>",

},
"gitHead": "684cee931129d8b4902c376032cea73ac28ac9fd"
"gitHead": "480e131ebc3b8dc0a96fd8d73fe559797a77b56a"
}
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