Comparing version 0.3.0 to 0.4.0
@@ -0,1 +1,5 @@ | ||
# 0.4.0 | ||
* Add lazy-load support to association targets in the `@assoc` decorator | ||
# 0.3.0 | ||
@@ -2,0 +6,0 @@ |
@@ -42,3 +42,3 @@ import { Model, ModelConstructor } from './model'; | ||
/** The target model of the association. */ | ||
target?: typeof Model; | ||
target?: AssociationTarget<any>; | ||
} | ||
@@ -50,2 +50,11 @@ /** The assoations defined on a model. */ | ||
/** | ||
* A target for an association. This can either | ||
* be a specific model or a function that lazily | ||
* loads the target model. | ||
* | ||
* The lazy load method can be used when there is circular dependency | ||
* issues. | ||
*/ | ||
export declare type AssociationTarget<T extends Model> = ModelConstructor<T> | (() => ModelConstructor<T>); | ||
/** | ||
* A decorator for a model association. | ||
@@ -65,2 +74,2 @@ * The association has a type and the model to associate to. | ||
*/ | ||
export declare function assoc<T extends Model>(type: AssociationType, target?: ModelConstructor<T>, options?: AssociationOptions): (ctor: Object, key: string | symbol) => void; | ||
export declare function assoc<T extends Model>(type: AssociationType, target?: AssociationTarget<T>, options?: AssociationOptions): (ctor: Object, key: string | symbol) => void; |
@@ -31,3 +31,2 @@ "use strict"; | ||
})(AssociationType = exports.AssociationType || (exports.AssociationType = {})); | ||
; | ||
// Promote association types to top level so they are usable as squell.HAS_ONE, like normal attr types. | ||
@@ -34,0 +33,0 @@ exports.HAS_ONE = AssociationType.HAS_ONE; |
{ | ||
"name": "modelsafe", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"main": "dist/index.js", | ||
@@ -19,2 +19,3 @@ "bugs": "https://github.com/creativecuriositystudio/modelsafe/issues", | ||
"scripts": { | ||
"prepush": "npm run lint && npm test", | ||
"prepublish": "tsc", | ||
@@ -33,6 +34,7 @@ "build": "tsc", | ||
"chai": "^3.5.0", | ||
"husky": "^0.13.2", | ||
"mocha": "^3.2.0", | ||
"ts-node": "^2.1.0", | ||
"tslint": "^4.0.2", | ||
"tslint-config-ccs": "^0.2.0", | ||
"tslint": "^4.3.0", | ||
"tslint-config-ccs": "^0.3.2", | ||
"typedoc": "^0.5.1" | ||
@@ -39,0 +41,0 @@ }, |
@@ -14,3 +14,3 @@ /** Contains the association types. */ | ||
BELONGS_TO_MANY | ||
}; | ||
} | ||
@@ -63,3 +63,3 @@ // Promote association types to top level so they are usable as squell.HAS_ONE, like normal attr types. | ||
/** The target model of the association. */ | ||
target?: typeof Model; | ||
target?: AssociationTarget<any>; | ||
} | ||
@@ -73,2 +73,12 @@ | ||
/** | ||
* A target for an association. This can either | ||
* be a specific model or a function that lazily | ||
* loads the target model. | ||
* | ||
* The lazy load method can be used when there is circular dependency | ||
* issues. | ||
*/ | ||
export type AssociationTarget<T extends Model> = ModelConstructor<T> | (() => ModelConstructor<T>); | ||
/** | ||
* A decorator for a model association. | ||
@@ -88,4 +98,4 @@ * The association has a type and the model to associate to. | ||
*/ | ||
export function assoc<T extends Model>(type: AssociationType, target?: ModelConstructor<T>, options?: AssociationOptions) { | ||
export function assoc<T extends Model>(type: AssociationType, target?: AssociationTarget<T>, options?: AssociationOptions) { | ||
return (ctor: Object, key: string | symbol) => defineAssociation(ctor, key, { ... options, type, target }); | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
253550
4209
9