@mikro-orm/knex
Advanced tools
Comparing version 4.0.0-alpha.5 to 4.0.0-alpha.6
export * from './AbstractSqlConnection'; | ||
export * from './AbstractSqlDriver'; | ||
export * from './AbstractSqlPlatform'; | ||
export * from './MonkeyPatchable'; | ||
export * from './SqlEntityManager'; | ||
@@ -5,0 +6,0 @@ export * from './SqlEntityRepository'; |
@@ -30,2 +30,3 @@ "use strict"; | ||
__exportStar(require("./AbstractSqlPlatform"), exports); | ||
__exportStar(require("./MonkeyPatchable"), exports); | ||
__exportStar(require("./SqlEntityManager"), exports); | ||
@@ -32,0 +33,0 @@ __exportStar(require("./SqlEntityRepository"), exports); |
{ | ||
"name": "@mikro-orm/knex", | ||
"version": "4.0.0-alpha.5", | ||
"version": "4.0.0-alpha.6", | ||
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.", | ||
@@ -54,7 +54,7 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@mikro-orm/core": "^4.0.0-alpha.5" | ||
"@mikro-orm/core": "^4.0.0-alpha.6" | ||
}, | ||
"peerDependencies": { | ||
"@mikro-orm/core": "^4.0.0-alpha.5" | ||
"@mikro-orm/core": "^4.0.0-alpha.6" | ||
} | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
this.key = key; | ||
const meta = parent && metadata.get(parent.entityName, false, false); | ||
const meta = parent && metadata.find(parent.entityName); | ||
if (meta && key) { | ||
@@ -20,0 +20,0 @@ core_1.Utils.splitPrimaryKeys(key).forEach(k => { |
@@ -9,3 +9,3 @@ "use strict"; | ||
const node = new ObjectCriteriaNode(metadata, entityName, parent, key); | ||
const meta = metadata.get(entityName, false, false); | ||
const meta = metadata.find(entityName); | ||
node.payload = Object.keys(payload).reduce((o, item) => { | ||
@@ -47,2 +47,8 @@ const prop = meta === null || meta === void 0 ? void 0 : meta.properties[item]; | ||
if (childNode.shouldInline(payload)) { | ||
const operators = Object.keys(payload).filter(k => core_1.Utils.isOperator(k, false)); | ||
operators.forEach(op => { | ||
const tmp = payload[op]; | ||
delete payload[op]; | ||
payload[`${alias}.${field}`] = Object.assign({ [op]: tmp }, (payload[`${alias}.${field}`] || {})); | ||
}); | ||
Object.assign(o, payload); | ||
@@ -49,0 +55,0 @@ } |
@@ -78,3 +78,3 @@ "use strict"; | ||
where(cond, params, operator) { | ||
cond = core_1.SmartQueryHelper.processWhere(cond, this.entityName, this.metadata); | ||
cond = core_1.QueryHelper.processWhere(cond, this.entityName, this.metadata); | ||
if (core_1.Utils.isString(cond)) { | ||
@@ -111,3 +111,3 @@ cond = { [`(${cond})`]: core_1.Utils.asArray(params) }; | ||
orderBy(orderBy) { | ||
orderBy = core_1.SmartQueryHelper.processWhere(orderBy, this.entityName, this.metadata); | ||
orderBy = core_1.QueryHelper.processWhere(orderBy, this.entityName, this.metadata); | ||
this._orderBy = internal_1.CriteriaNode.create(this.metadata, this.entityName, orderBy).process(this); | ||
@@ -182,3 +182,3 @@ return this; | ||
this.helper.getLockSQL(qb, this.lockMode); | ||
this.helper.finalize(this.type, qb, this.metadata.get(this.entityName, false, false)); | ||
this.helper.finalize(this.type, qb, this.metadata.find(this.entityName)); | ||
return qb; | ||
@@ -207,4 +207,4 @@ } | ||
const res = await this.driver.getConnection(type).execute(this.getKnexQuery(), [], method); | ||
const meta = this.metadata.get(this.entityName, false, false); | ||
if (!mapResults) { | ||
const meta = this.metadata.find(this.entityName); | ||
if (!mapResults || !meta) { | ||
return res; | ||
@@ -235,3 +235,3 @@ } | ||
const [a, f] = alias.split('.'); | ||
const meta = this.metadata.get(a, false, false); | ||
const meta = this.metadata.find(a); | ||
/* istanbul ignore next */ | ||
@@ -264,3 +264,3 @@ alias = ((_a = meta === null || meta === void 0 ? void 0 : meta.properties[f]) === null || _a === void 0 ? void 0 : _a.fieldNames[0]) || alias; | ||
this._aliasMap[alias] = prop.type; | ||
cond = core_1.SmartQueryHelper.processWhere(cond, this.entityName, this.metadata); | ||
cond = core_1.QueryHelper.processWhere(cond, this.entityName, this.metadata); | ||
const aliasedName = `${fromAlias}.${prop.name}`; | ||
@@ -365,4 +365,5 @@ if (prop.reference === core_1.ReferenceType.ONE_TO_MANY) { | ||
} | ||
const meta = this.metadata.get(this.entityName, false, false); | ||
const meta = this.metadata.find(this.entityName); | ||
this._populate.forEach(({ field }) => { | ||
var _a; | ||
const [fromAlias, fromField] = this.helper.splitField(field); | ||
@@ -373,6 +374,6 @@ const aliasedField = `${fromAlias}.${fromField}`; | ||
} | ||
if (this.metadata.has(field)) { // pivot table entity | ||
if ((_a = this.metadata.find(field)) === null || _a === void 0 ? void 0 : _a.pivotTable) { // pivot table entity | ||
this.autoJoinPivotTable(field); | ||
} | ||
else if (this.helper.isOneToOneInverse(field)) { | ||
else if (meta && this.helper.isOneToOneInverse(field)) { | ||
const prop = meta.properties[field]; | ||
@@ -383,3 +384,3 @@ this._joins[prop.name] = this.helper.joinOneToReference(prop, this.alias, `e${this.aliasCounter++}`, 'leftJoin'); | ||
}); | ||
if (this.metadata.has(this.entityName) && (((_a = this._fields) === null || _a === void 0 ? void 0 : _a.includes('*')) || ((_b = this._fields) === null || _b === void 0 ? void 0 : _b.includes(`${this.alias}.*`)))) { | ||
if (meta && (((_a = this._fields) === null || _a === void 0 ? void 0 : _a.includes('*')) || ((_b = this._fields) === null || _b === void 0 ? void 0 : _b.includes(`${this.alias}.*`)))) { | ||
Object.values(meta.properties) | ||
@@ -393,8 +394,8 @@ .filter(prop => prop.formula) | ||
} | ||
core_1.SmartQueryHelper.processParams([this._data, this._cond, this._having]); | ||
core_1.QueryHelper.processParams([this._data, this._cond, this._having]); | ||
this.finalized = true; | ||
if (this.flags.has(core_1.QueryFlag.PAGINATE) && this._limit > 0) { | ||
if (meta && this.flags.has(core_1.QueryFlag.PAGINATE) && this._limit > 0) { | ||
this.wrapPaginateSubQuery(meta); | ||
} | ||
if (this.flags.has(core_1.QueryFlag.UPDATE_SUB_QUERY) || this.flags.has(core_1.QueryFlag.DELETE_SUB_QUERY)) { | ||
if (meta && (this.flags.has(core_1.QueryFlag.UPDATE_SUB_QUERY) || this.flags.has(core_1.QueryFlag.DELETE_SUB_QUERY))) { | ||
this.wrapModifySubQuery(meta); | ||
@@ -401,0 +402,0 @@ } |
@@ -43,3 +43,3 @@ "use strict"; | ||
data = Object.assign({}, data); // copy first | ||
const meta = this.metadata.get(this.entityName, false, false); | ||
const meta = this.metadata.find(this.entityName); | ||
Object.keys(data).forEach(k => { | ||
@@ -144,3 +144,3 @@ if (!(meta === null || meta === void 0 ? void 0 : meta.properties[k])) { | ||
getTableName(entityName) { | ||
const meta = this.metadata.get(entityName, false, false); | ||
const meta = this.metadata.find(entityName); | ||
return meta ? meta.collection : entityName; | ||
@@ -339,3 +339,3 @@ } | ||
} | ||
const meta = this.metadata.get(this.entityName, false, false); | ||
const meta = this.metadata.find(this.entityName); | ||
if (lockMode === core_1.LockMode.OPTIMISTIC && meta && !meta.versionProperty) { | ||
@@ -346,3 +346,3 @@ throw core_1.ValidationError.lockFailed(this.entityName); | ||
updateVersionProperty(qb) { | ||
const meta = this.metadata.get(this.entityName, false, false); | ||
const meta = this.metadata.find(this.entityName); | ||
if (!meta || !meta.versionProperty) { | ||
@@ -391,3 +391,3 @@ return; | ||
const entityName = this.aliasMap[alias] || this.entityName; | ||
const meta = this.metadata.get(entityName, false, false); | ||
const meta = this.metadata.find(entityName); | ||
return meta ? meta.properties[field] : undefined; | ||
@@ -394,0 +394,0 @@ } |
@@ -152,2 +152,3 @@ <h1 align="center"> | ||
- [Composite and Foreign Keys as Primary Key](https://mikro-orm.io/composite-keys/) | ||
- [Filters](https://mikro-orm.io/filters/) | ||
- [Using `QueryBuilder`](https://mikro-orm.io/query-builder/) | ||
@@ -154,0 +155,0 @@ - [Preloading Deeply Nested Structures via populate](https://mikro-orm.io/nested-populate/) |
@@ -148,2 +148,5 @@ "use strict"; | ||
} | ||
if (meta.comment) { | ||
table.comment(meta.comment); | ||
} | ||
const createIndex = (index, unique) => { | ||
@@ -303,2 +306,3 @@ const properties = core_1.Utils.flatten(core_1.Utils.asArray(index.properties).map(prop => meta.properties[prop].fieldNames)); | ||
core_1.Utils.runIfNotEmpty(() => col.defaultTo(prop.defaultRaw ? this.knex.raw(prop.defaultRaw) : null), !sameDefault); | ||
core_1.Utils.runIfNotEmpty(() => col.comment(prop.comment), prop.comment); | ||
return col; | ||
@@ -305,0 +309,0 @@ } |
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
155898
45
3061
406