From 29a630aa47eea09f92a51d8daddc6870b56606eb Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Tue, 15 Dec 2015 18:33:19 +0200 Subject: [PATCH] revert: Switch back to type-less Transforms as it would otherwise be a breaking change --- lib/Decorators.ts | 2 +- lib/Instance.ts | 2 +- lib/InstanceInterface.ts | 2 +- lib/Model.ts | 2 +- lib/Transforms.ts | 2 +- test/Decorators.ts | 2 +- test/Model.ts | 2 +- test/Transforms.ts | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Decorators.ts b/lib/Decorators.ts index 65fd6be..371bb20 100644 --- a/lib/Decorators.ts +++ b/lib/Decorators.ts @@ -110,7 +110,7 @@ export function Transform(fromDB: (value: any, property: string, model: Model, property: string) { let staticTarget: InstanceImplementation = >(target.constructor || target); - staticTarget.transforms = _.clone(staticTarget.transforms || >{}) + staticTarget.transforms = _.clone(staticTarget.transforms || {}) staticTarget.transforms[property] = { fromDB: fromDB, toDB: toDB diff --git a/lib/Instance.ts b/lib/Instance.ts index f055efb..64e914a 100644 --- a/lib/Instance.ts +++ b/lib/Instance.ts @@ -113,7 +113,7 @@ export class Instance { /** * The transformations which should be applied to properties of documents of this type. */ - static transforms: Transforms = { + static transforms: Transforms = { }; diff --git a/lib/InstanceInterface.ts b/lib/InstanceInterface.ts index df3836f..5b8cd9e 100644 --- a/lib/InstanceInterface.ts +++ b/lib/InstanceInterface.ts @@ -124,5 +124,5 @@ export interface InstanceImplementation; + transforms?: Transforms; } \ No newline at end of file diff --git a/lib/Model.ts b/lib/Model.ts index fd8a9c7..fe664df 100644 --- a/lib/Model.ts +++ b/lib/Model.ts @@ -211,7 +211,7 @@ export class Model { return this._Instance; } - private _transforms: Transforms; + private _transforms: Transforms; /** * Gets the transforms which are applied whenever a document is received from the database, or diff --git a/lib/Transforms.ts b/lib/Transforms.ts index 7f1b4d9..3d60b7e 100644 --- a/lib/Transforms.ts +++ b/lib/Transforms.ts @@ -2,7 +2,7 @@ import MongoDB = require('mongodb'); import {Model} from './Model'; import * as BSON from './BSON'; -export interface Transforms { +export interface Transforms { /** * A transform which is applied to the entire document. */ diff --git a/test/Decorators.ts b/test/Decorators.ts index 029b4e7..6e5ec92 100644 --- a/test/Decorators.ts +++ b/test/Decorators.ts @@ -21,7 +21,7 @@ function VersionValidator(schema, data) { @Iridium.Property('version', 'version') @Iridium.Property('optional2', Boolean, false) class Test extends Iridium.Instance implements TestDocument { - static transforms: Iridium.Transforms = {}; + static transforms: Iridium.Transforms = {}; static indexes = []; @Iridium.ObjectID diff --git a/test/Model.ts b/test/Model.ts index 043ea3a..1425f04 100644 --- a/test/Model.ts +++ b/test/Model.ts @@ -22,7 +22,7 @@ class Test extends Iridium.Instance implements TestDocument } class TestWithCustomID extends Test { - static transforms: Iridium.Transforms = { + static transforms: Iridium.Transforms = { _id: { fromDB: x => x * 10, toDB: x => x / 10 diff --git a/test/Transforms.ts b/test/Transforms.ts index dc08e1f..b03d633 100644 --- a/test/Transforms.ts +++ b/test/Transforms.ts @@ -23,7 +23,7 @@ class Person extends Iridium.Instance { avatar: Buffer }; - static transforms: Iridium.Transforms = { + static transforms: Iridium.Transforms = { email: { fromDB: x => x.toUpperCase(), toDB: x => x.toLowerCase().trim()