Comparing version 0.1.5-alpha.13 to 0.1.5-alpha.14
const { And } = require('./And') | ||
const { DatabaseModelBase } = require('../models/DatabaseModelBase') | ||
const { filterUnique } = require('../filters') | ||
const { getModelName } = require('../models/ModelRegistry') | ||
const { ImmutablePropModel } = require('./props') | ||
@@ -9,3 +8,5 @@ const { parseFieldObjects } = require('../models/AttrModel') | ||
const { QueryColumnGroup } = require('./QueryColumnGroup') | ||
const { QueryColumn } = require('./QueryColumn') | ||
const { QueryError } = require('./errors') | ||
const { QueryJoin } = require('./QueryJoin') | ||
const { QueryTable } = require('./QueryTable') | ||
@@ -41,5 +42,6 @@ | ||
if (value.prototype && value.prototype instanceof DatabaseModelBase) { | ||
const [selection] = this.getModelFields(value) | ||
const [selection, joins] = this.getModelFields(value) | ||
return this.setProp('target', value.table) | ||
.setProp('selection', selection, true) | ||
.setProp('joins', joins, true) | ||
.setProp('model', value, true) | ||
@@ -83,14 +85,11 @@ } | ||
joins.push( | ||
new QueryTable({ | ||
new QueryJoin({ | ||
name: obj.table, | ||
alias: obj.table, | ||
on: [ | ||
{ | ||
left: { source: obj.table, name: obj.pkName }, | ||
column: { | ||
source: model.table, | ||
name: model.pkName | ||
} | ||
} | ||
] | ||
conditions: { | ||
[model.pkName]: new QueryColumn({ | ||
source: obj.table, | ||
name: obj.pkName | ||
}) | ||
} | ||
}) | ||
@@ -102,4 +101,3 @@ ) | ||
source: obj.table, | ||
columns: fieldNames, | ||
prefix: getModelName(obj) | ||
columns: fieldNames | ||
}) | ||
@@ -106,0 +104,0 @@ ) |
@@ -21,7 +21,10 @@ const { DatabaseModelBase } = require('./DatabaseModelBase') | ||
static get objects () { | ||
if (!this.managerInstance) { | ||
const Manager = this.manager | ||
this.managerInstance = new Manager(this) | ||
const cache = Object.getOwnPropertyDescriptor(this, 'managerInstance') | ||
if (cache && cache.value) { | ||
return cache.value | ||
} | ||
return this.managerInstance | ||
const Manager = this.manager | ||
const value = new Manager(this) | ||
Object.defineProperty(this, 'managerInstance', { value }) | ||
return value | ||
} | ||
@@ -28,0 +31,0 @@ |
@@ -0,1 +1,2 @@ | ||
const { Delete } = require('../db/Delete') | ||
const { Select } = require('../db/Select') | ||
@@ -12,2 +13,6 @@ | ||
get delete () { | ||
return Delete.fromDb(this.db).target(this.model) | ||
} | ||
get query () { | ||
@@ -14,0 +19,0 @@ return Select.fromDb(this.db).from(this.model) |
{ | ||
"name": "djorm", | ||
"version": "0.1.5-alpha.13", | ||
"version": "0.1.5-alpha.14", | ||
"description": "Django like ORM framework", | ||
@@ -35,3 +35,3 @@ "author": "Pavel Žák <pavel@zak.global>", | ||
}, | ||
"gitHead": "ed93c1475e18b00733f9e62b2c6006f6c08c12c5" | ||
"gitHead": "66857fc3c827e82059792082a0e69654f8828088" | ||
} |
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
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
50001
1772