Comparing version 0.0.5 to 0.0.6
@@ -24,3 +24,21 @@ /* UNIQORM | ||
constructor() { | ||
constructor(orm, meta) { | ||
this._orm = orm; | ||
const aliases = []; | ||
this.tableName = meta.tableName; | ||
this.tableAlias = meta.tableName.substring(0, 1).toLowerCase(); | ||
aliases.push(this.tableAlias); | ||
for (const relation of this._relations) { | ||
const t = relation.foreignModel.meta.tableName; | ||
const aa = t.substring(t, 1).toLowerCase(); | ||
let a = aa; | ||
let i = 1; | ||
while (aliases.indexOf(a) >= 0) | ||
a = aa + (++i); | ||
aliases.push(a); | ||
//noinspection JSUndefinedPropertyAssignment | ||
relation.tableName = t; | ||
//noinspection JSUndefinedPropertyAssignment | ||
relation.tableAlias = a; | ||
} | ||
} | ||
@@ -81,21 +99,4 @@ | ||
//noinspection JSUnusedGlobalSymbols | ||
constructor() { | ||
super(); | ||
const aliases = []; | ||
this.tableName = meta.tableName; | ||
this.tableAlias = meta.tableName.substring(0, 1).toLowerCase(); | ||
aliases.push(this.tableAlias); | ||
for (const relation of this._relations) { | ||
const t = relation.foreignModel.meta.tableName; | ||
const aa = t.substring(t, 1).toLowerCase(); | ||
let a = aa; | ||
let i = 1; | ||
while (aliases.indexOf(a) >= 0) | ||
a = aa + (++i); | ||
aliases.push(a); | ||
//noinspection JSUndefinedPropertyAssignment | ||
relation.tableName = t; | ||
//noinspection JSUndefinedPropertyAssignment | ||
relation.tableAlias = a; | ||
} | ||
constructor(orm) { | ||
super(orm, meta); | ||
} | ||
@@ -102,0 +103,0 @@ }; |
@@ -92,3 +92,3 @@ /* UNIQORM | ||
const database = model.schema.owner.dbPool; | ||
const defaultSchema = database.schema; | ||
const defaultSchema = this.model._orm.defaultSchema || database.schema; | ||
const schema = model.schema.name && | ||
@@ -112,5 +112,2 @@ model.schema.name !== defaultSchema ? model.schema.name : ''; | ||
for (const item of selFields) { | ||
if (item === 'KOZA_BITIS_TARIHI') { | ||
let a = 1; | ||
} | ||
const f = model.getFieldInfo(item); | ||
@@ -187,4 +184,4 @@ assert(f, `Field (${item}) is not defined in model (${model.name})`); | ||
/*console.log('--------'); | ||
console.log(database.serializer.build(statement).sql); | ||
console.log('--------');*/ | ||
console.log(database.serializer.build(statement).sql); | ||
console.log('--------');*/ | ||
return statement; | ||
@@ -191,0 +188,0 @@ } |
@@ -15,6 +15,7 @@ /* UNIQORM | ||
const assert = require('assert'); | ||
const util = require('util'); | ||
const waterfall = require('putil-waterfall'); | ||
const Promisify = require('putil-promisify'); | ||
const defaultSchemaSymbol = Symbol('default-schema'); | ||
const noSchemaSymbol = Symbol('no-schema'); | ||
@@ -30,3 +31,3 @@ /** | ||
self.dbPool = dbPool; | ||
self.defaultSchema = undefined; | ||
self.defaultSchema = dbPool.schema; | ||
@@ -53,3 +54,3 @@ /* Create a case in sensitive map*/ | ||
self.schemas[self.defaultSchema || defaultSchemaSymbol] = new Schema(this, ''); | ||
self.schemas[noSchemaSymbol] = new Schema(this, ''); | ||
} | ||
@@ -74,3 +75,3 @@ | ||
modelName : modelName}`); | ||
return Reflect.construct(ctor, []); | ||
return Reflect.construct(ctor, [this]); | ||
} | ||
@@ -86,3 +87,4 @@ | ||
getSchema(schemaName) { | ||
return this.schemas[schemaName || this.defaultSchema || defaultSchemaSymbol]; | ||
return this.schemas[schemaName || this.defaultSchema || | ||
noSchemaSymbol]; | ||
} | ||
@@ -185,4 +187,8 @@ | ||
}); | ||
} | ||
close(callback) { | ||
this.dbPool.close(callback); | ||
} | ||
} | ||
@@ -189,0 +195,0 @@ |
{ | ||
"name": "uniqorm", | ||
"description": "Easy to use, multi-dialect ORM framework for JavaScript", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Panates Ltd.", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
1793
51923