@fxjs/orm
Advanced tools
Comparing version 1.11.2 to 1.11.3
@@ -7,3 +7,8 @@ /// <reference path="_common.d.ts" /> | ||
type AssociationKeyComputation = Function | string | ||
/** | ||
* @type.function: (model_name: string, idkey: string) => string | ||
* | ||
* @string.default: `{model_name}_${idkey}` | ||
*/ | ||
type AssociationKeyComputation = (model_name: string, idkey: string) => string | string | ||
interface AssociationDefinitionOptions { | ||
@@ -10,0 +15,0 @@ /** |
@@ -194,3 +194,2 @@ /// <reference types="@fxjs/sql-query" /> | ||
table: string | ||
properties: FxOrmProperty.NormalizedPropertyHash | ||
allProperties: FxOrmProperty.NormalizedPropertyHash | ||
@@ -197,0 +196,0 @@ indexes: string[] |
@@ -44,3 +44,3 @@ /// <reference types="@fxjs/sql-query" /> | ||
name?: string | ||
klass?: 'primary' | 'hasOne' | ||
klass?: FxOrmProperty.KlassType | ||
} | false | ||
@@ -300,3 +300,3 @@ ): FxOrmProperty.NormalizedProperty | ||
key?: boolean | ||
klass?: 'primary' | 'hasOne' | ||
klass?: FxOrmProperty.KlassType | ||
alwaysValidate?: boolean | ||
@@ -303,0 +303,0 @@ enumerable?: boolean |
declare namespace FxOrmProperty { | ||
/** | ||
* @description key linked association type | ||
* - 'primary': means this property is for column defined as 'primary' | ||
* - 'hasOne': means this property is for column used as asscociated key in 'hasOne' assciation | ||
*/ | ||
type KlassType = 'primary' | 'hasOne' | ||
interface CustomPropertyType extends FxOrmSqlDDLSync__Driver.CustomPropertyType { | ||
@@ -25,3 +32,3 @@ datastoreType: { | ||
key?: boolean | ||
klass?: 'primary' | 'hasOne' | ||
klass?: KlassType | ||
lazyload?: boolean | ||
@@ -28,0 +35,0 @@ alwaysValidate?: boolean |
v1.11.2 / 2019-07-21 | ||
v1.11.3 / 2019-08-19 | ||
================== | ||
* package, sql-ddl-sync: Release v0.6.2 | ||
* feat, main: add comment for type `FxOrmAssociation.AssociationKeyComputation`. | ||
* package, sql-ddl-sync: use better strategy to check if one collection has column for `mysql`, add test cases about it. | ||
* package, sql-ddl-sync: allow processCollection when strategy is 'mixed'. | ||
* feat, main: better semantic declaration, add some comments. | ||
* packages, sql-ddl-sync: Release v0.6.1 | ||
* code clean. | ||
v1.11.2 / 2019-07-21 | ||
==================== | ||
* Release v1.11.2 | ||
* upgrade sql-ddl-sync | ||
@@ -6,0 +18,0 @@ * packages, sql-ddl-sync: Release v0.6.0 |
@@ -46,3 +46,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
altName: Model.table | ||
}) || Utilities.formatField(Model, Model.table, false, false), | ||
}) || Utilities.formatAssociatedField(Model, Model.table, false, false), | ||
getAccessor: assoc_options.getAccessor || _utils_1.defineAssociationAccessorMethodName(_utils_1.ACCESSOR_KEYS.get, associationSemanticNameCore), | ||
@@ -49,0 +49,0 @@ setAccessor: assoc_options.setAccessor || _utils_1.defineAssociationAccessorMethodName(_utils_1.ACCESSOR_KEYS.set, associationSemanticNameCore), |
@@ -68,9 +68,9 @@ /// <reference lib="es5" /> | ||
}) || | ||
Utilities.formatField(Model, Model.table, true, assoc_options.reversed), { makeKey: makeKey, required: true }); | ||
Utilities.formatAssociatedField(Model, Model.table, true, assoc_options.reversed), { makeKey: makeKey, required: true }); | ||
mergeAssocId = Utilities.convertPropToJoinKeyProp(Utilities.wrapFieldObject({ | ||
field: assoc_options.mergeAssocId, model: OtherModel, altName: name | ||
}) || | ||
Utilities.formatField(OtherModel, name, true, assoc_options.reversed), { makeKey: makeKey, required: true }); | ||
Utilities.formatAssociatedField(OtherModel, name, true, assoc_options.reversed), { makeKey: makeKey, required: true }); | ||
const associationSemanticNameCore = assoc_options.name || Utilities.formatNameFor("assoc:hasMany", name); | ||
const fieldhash = Utilities.wrapFieldObject({ field: assoc_options.field, model: OtherModel, altName: Model.table }) || Utilities.formatField(Model, name, true, assoc_options.reversed); | ||
const fieldhash = Utilities.wrapFieldObject({ field: assoc_options.field, model: OtherModel, altName: Model.table }) || Utilities.formatAssociatedField(Model, name, true, assoc_options.reversed); | ||
const association = { | ||
@@ -77,0 +77,0 @@ name: name, |
@@ -38,3 +38,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
if (!association.field) { | ||
association.field = Utilities.formatField(association.model, association.name, association.required, association.reversed); | ||
association.field = Utilities.formatAssociatedField(association.model, association.name, association.required, association.reversed); | ||
} | ||
@@ -137,3 +137,2 @@ else if (!association.__for_extension) { | ||
catch (error) { | ||
console.log('error', error); | ||
return false; | ||
@@ -140,0 +139,0 @@ } |
@@ -36,2 +36,9 @@ /// <reference lib="es2017" /> | ||
const fieldToPropertyMap = {}; | ||
/** | ||
* @description compared to m_opts.properties, allProperties means all properties including: | ||
* 1. association key properties, such as `{assoc_name}_{id}` property in default `hasOne` case, | ||
* which was not included by m_opts.properties; | ||
* 2. dynamic added properties by `model.addProperty(...)`, in fact, all association-about properties | ||
* were added by `addProperty` method | ||
*/ | ||
const allProperties = {}; | ||
@@ -189,3 +196,2 @@ const keyProperties = []; | ||
table: m_opts.table, | ||
properties: m_opts.properties, | ||
allProperties: allProperties, | ||
@@ -192,0 +198,0 @@ indexes: m_opts.indexes || [], |
@@ -257,3 +257,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
*/ | ||
function formatField(model, name, required, reversed) { | ||
function formatAssociatedField(model, name, required, reversed) { | ||
let fields = {}, field_opts, field_name; | ||
@@ -302,3 +302,3 @@ var keys = model.id; | ||
} | ||
exports.formatField = formatField; | ||
exports.formatAssociatedField = formatAssociatedField; | ||
; | ||
@@ -305,0 +305,0 @@ // If the parent associations key is `serial`, the join tables |
{ | ||
"name": "@fxjs/orm", | ||
"version": "1.11.2", | ||
"version": "1.11.3", | ||
"description": "Object Relational Mapping for fibjs", | ||
@@ -46,3 +46,3 @@ "main": "lib", | ||
"@fxjs/orm-core": "^0.0.1", | ||
"@fxjs/sql-ddl-sync": "^0.6.0", | ||
"@fxjs/sql-ddl-sync": "^0.6.2", | ||
"@fxjs/sql-query": "^0.5.1", | ||
@@ -49,0 +49,0 @@ "fib-pool": "^1.5.3", |
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
375665
8310
Updated@fxjs/sql-ddl-sync@^0.6.2