Comparing version 0.1.5-alpha.16 to 0.1.6-alpha.0
let currentConfig = { | ||
databases: {} | ||
name: 'djorm', | ||
apps: [], | ||
databases: {}, | ||
logger: { | ||
level: 'info', | ||
transport: null, | ||
options: {} | ||
} | ||
} | ||
const configure = config => { | ||
currentConfig = config | ||
currentConfig = { ...currentConfig, ...config } | ||
} | ||
@@ -14,13 +21,15 @@ | ||
const settings = currentConfig | ||
if (settings.apps) { | ||
require('./init/apps').init(settings) | ||
} | ||
require('./init/logger').init(settings) | ||
if (settings.databases) { | ||
const { Database } = require('./db/Database') | ||
const { configDb } = require('./db/DatabasePool') | ||
Object.entries(settings.databases).map(([dbName, dbConfig]) => | ||
configDb(Database.resolveDriver(dbConfig), dbName) | ||
) | ||
require('./init/databases').init(settings.databases) | ||
} | ||
} | ||
const shutdown = async () => {} | ||
const shutdown = async () => { | ||
require('./init/apps').shutdown(currentConfig) | ||
require('./init/logger').shutdown() | ||
} | ||
@@ -31,6 +40,3 @@ module.exports = { | ||
shutdown, | ||
getSettings: () => currentConfig, | ||
get settings () { | ||
return currentConfig | ||
} | ||
getSettings: () => currentConfig | ||
} |
const { DatabaseMapper } = require('./DatabaseMapper') | ||
const { NotImplemented } = require('../errors') | ||
const { PropModel } = require('./props') | ||
const { debug, trace } = require('../logger') | ||
@@ -26,4 +27,6 @@ class Database extends PropModel { | ||
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() | ||
@@ -58,2 +61,3 @@ } | ||
await this.waitForConnection() | ||
debug(str) | ||
return await this.queryDb(str) | ||
@@ -64,2 +68,3 @@ } | ||
await this.waitForConnection() | ||
debug(str) | ||
return await this.execDb(str) | ||
@@ -66,0 +71,0 @@ } |
@@ -137,3 +137,3 @@ const { FieldError } = require('../errors') | ||
return this.constructor.fieldObjects | ||
.filter(([key, field]) => field.db) | ||
.filter(([key, field]) => !field.private) | ||
.reduce( | ||
@@ -171,2 +171,3 @@ (aggr, [key, field]) => ({ | ||
static default = new Field() | ||
static private = new Field({ default: false }) | ||
static secret = new Field() | ||
@@ -173,0 +174,0 @@ static validator = new Field() |
@@ -122,2 +122,10 @@ const { DatabaseModelBase } = require('./DatabaseModelBase') | ||
async reload () { | ||
const obj = await this.constructor.objects.get({ | ||
[this.constructor.pkName]: this.pk | ||
}) | ||
const values = obj.serializeDbValues() | ||
return this.setValues(values) | ||
} | ||
async delete () { | ||
@@ -124,0 +132,0 @@ let obj = this.constructor |
{ | ||
"name": "djorm", | ||
"version": "0.1.5-alpha.16", | ||
"version": "0.1.6-alpha.0", | ||
"description": "Django like ORM framework", | ||
@@ -18,2 +18,3 @@ "author": "Pavel Žák <pavel@zak.global>", | ||
"fields", | ||
"init", | ||
"models", | ||
@@ -34,5 +35,6 @@ "*.js" | ||
"camelcase": "^6.2.0", | ||
"moment-timezone": "^0.5.33" | ||
"moment-timezone": "^0.5.33", | ||
"pino": "^6.11.3" | ||
}, | ||
"gitHead": "ab57b5a8093139695d9cd8470d571ea3e7c961f3" | ||
"gitHead": "208cedc10ee05f04e30ac1083a92bfe19a85e6f7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53225
61
1899
3
3
+ Addedpino@^6.11.3
+ Addedatomic-sleep@1.0.0(transitive)
+ Addedfast-redact@3.5.0(transitive)
+ Addedfast-safe-stringify@2.1.1(transitive)
+ Addedflatstr@1.0.12(transitive)
+ Addedpino@6.14.0(transitive)
+ Addedpino-std-serializers@3.2.0(transitive)
+ Addedprocess-warning@1.0.0(transitive)
+ Addedquick-format-unescaped@4.0.4(transitive)
+ Addedsonic-boom@1.4.1(transitive)