From 22726c075179d7ecaf22960d4c283752b11160e8 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Fri, 15 Jan 2016 16:51:34 +0900 Subject: [PATCH] change to use `this` type --- sequelize/sequelize-tests.ts | 26 +++++++++--------- sequelize/sequelize.d.ts | 52 ++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/sequelize/sequelize-tests.ts b/sequelize/sequelize-tests.ts index 74c7e06e8..522f51dab 100644 --- a/sequelize/sequelize-tests.ts +++ b/sequelize/sequelize-tests.ts @@ -8,7 +8,7 @@ import Sequelize = require("sequelize"); // interface AnyAttributes { }; -interface AnyInstance extends Sequelize.Instance { }; +interface AnyInstance extends Sequelize.Instance { }; var s = new Sequelize( '' ); var sequelize = s; @@ -32,7 +32,7 @@ interface GUserAttributes { username? : string; } -interface GUserInstance extends Sequelize.Instance {} +interface GUserInstance extends Sequelize.Instance {} var GUser = s.define( 'user', { id: Sequelize.INTEGER, username : Sequelize.STRING }); GUser.create({ id : 1, username : 'one' }).then( ( guser ) => guser.save() ); @@ -47,7 +47,7 @@ interface GTaskAttributes { revision? : number; name? : string; } -interface GTaskInstance extends Sequelize.Instance { +interface GTaskInstance extends Sequelize.Instance { upRevision(): void; } var GTask = s.define( 'task', { revision : Sequelize.INTEGER, name : Sequelize.STRING }); @@ -347,7 +347,7 @@ interface ProductAttributes { price?: number; }; -interface ProductInstance extends Sequelize.Instance, ProductAttributes { +interface ProductInstance extends Sequelize.Instance, ProductAttributes { // hasOne association mixins: getBarcode: Sequelize.HasOneGetAssociationMixin; setBarcode: Sequelize.HasOneSetAssociationMixin; @@ -365,7 +365,7 @@ interface BarcodeAttributes { dateIssued?: Date; }; -interface BarcodeInstance extends Sequelize.Instance, BarcodeAttributes { +interface BarcodeInstance extends Sequelize.Instance, BarcodeAttributes { // belongsTo association mixins: getProduct: Sequelize.BelongsToGetAssociationMixin; setProduct: Sequelize.BelongsToSetAssociationMixin; @@ -378,7 +378,7 @@ interface WarehouseAttributes { capacity?: number; }; -interface WarehouseInstance extends Sequelize.Instance, WarehouseAttributes { +interface WarehouseInstance extends Sequelize.Instance, WarehouseAttributes { // hasMany association mixins: getProducts: Sequelize.HasManyGetAssociationsMixin; setProducts: Sequelize.HasManySetAssociationsMixin; @@ -410,7 +410,7 @@ interface BranchAttributes { rank?: number; }; -interface BranchInstance extends Sequelize.Instance, BranchAttributes { +interface BranchInstance extends Sequelize.Instance, BranchAttributes { // belongsToMany association mixins: getWarehouses: Sequelize.BelongsToManyGetAssociationsMixin; setWarehouses: Sequelize.BelongsToManySetAssociationsMixin; @@ -440,7 +440,7 @@ interface WarehouseBranchAttributes { distance?: number; }; -interface WarehouseBranchInstance extends Sequelize.Instance, WarehouseBranchAttributes { }; +interface WarehouseBranchInstance extends Sequelize.Instance, WarehouseBranchAttributes { }; interface CustomerAttributes { id?: number; @@ -448,7 +448,7 @@ interface CustomerAttributes { credit?: number; }; -interface CustomerInstance extends Sequelize.Instance, CustomerAttributes { +interface CustomerInstance extends Sequelize.Instance, CustomerAttributes { // belongsToMany association mixins: getBranches: Sequelize.BelongsToManyGetAssociationsMixin; setBranches: Sequelize.BelongsToManySetAssociationsMixin; @@ -633,11 +633,11 @@ new s.ConnectionTimedOutError( new Error( 'original connection error message' ) // https://github.com/sequelize/sequelize/blob/v3.4.1/test/integration/hooks.test.js // -User.addHook( 'afterCreate', function( instance : Sequelize.Instance, options : Object, next : Function ) { next(); } ); -User.addHook( 'afterCreate', 'myHook', function( instance : Sequelize.Instance, options : Object, next : Function) { next(); } ); +User.addHook( 'afterCreate', function( instance : Sequelize.Instance, options : Object, next : Function ) { next(); } ); +User.addHook( 'afterCreate', 'myHook', function( instance : Sequelize.Instance, options : Object, next : Function) { next(); } ); s.addHook( 'beforeInit', function( config : Object, options : Object ) { } ); -User.hook( 'afterCreate', 'myHook', function( instance : Sequelize.Instance, options : Object, next : Function) { next(); } ); -User.hook( 'afterCreate', 'myHook', function( instance : Sequelize.Instance, options : Object, next : Function ) { next(); } ); +User.hook( 'afterCreate', 'myHook', function( instance : Sequelize.Instance, options : Object, next : Function) { next(); } ); +User.hook( 'afterCreate', 'myHook', function( instance : Sequelize.Instance, options : Object, next : Function ) { next(); } ); User.removeHook( 'afterCreate', 'myHook' ); diff --git a/sequelize/sequelize.d.ts b/sequelize/sequelize.d.ts index e33b4b8d7..0dcd61e86 100644 --- a/sequelize/sequelize.d.ts +++ b/sequelize/sequelize.d.ts @@ -2690,7 +2690,7 @@ declare module "sequelize" { * * @see Sequelize.define for more information about getters and setters */ - interface Instance { + interface Instance { /** * Returns true if this instance has not yet been persisted to the database @@ -2702,7 +2702,7 @@ declare module "sequelize" { * * @see Model */ - Model : Model; + Model : Model; /** * A reference to the sequelize instance @@ -2759,10 +2759,10 @@ declare module "sequelize" { * @param options.raw If set to true, field and virtual setters will be ignored * @param options.reset Clear all previously set data values */ - set( key : string, value : any, options? : InstanceSetOptions ) : TInstance; - set( keys : Object, options? : InstanceSetOptions ) : TInstance; - setAttributes( key : string, value : any, options? : InstanceSetOptions ) : TInstance; - setAttributes( keys : Object, options? : InstanceSetOptions ) : TInstance; + set( key : string, value : any, options? : InstanceSetOptions ) : this; + set( keys : Object, options? : InstanceSetOptions ) : this; + setAttributes( key : string, value : any, options? : InstanceSetOptions ) : this; + setAttributes( keys : Object, options? : InstanceSetOptions ) : this; /** * If changed is called with a string it will return a boolean indicating whether the value of that key in @@ -2787,7 +2787,7 @@ declare module "sequelize" { * called with an instance of `Sequelize.ValidationError`. This error will have a property for each of the * fields for which validation failed, with the error message for that field. */ - save( options? : InstanceSaveOptions ) : Promise; + save( options? : InstanceSaveOptions ) : Promise; /** * Refresh the current instance in-place, i.e. update the object with current data from the DB and return @@ -2795,7 +2795,7 @@ declare module "sequelize" { * return a new instance. With this method, all references to the Instance are updated with the new data * and no new objects are created. */ - reload( options? : FindOptions ) : Promise; + reload( options? : FindOptions ) : Promise; /** * Validate the attribute of this instance according to validation rules set in the model definition. @@ -2810,10 +2810,10 @@ declare module "sequelize" { /** * This is the same as calling `set` and then calling `save`. */ - update( key : string, value : any, options? : InstanceUpdateOptions ) : Promise; - update( keys : Object, options? : InstanceUpdateOptions ) : Promise; - updateAttributes( key : string, value : any, options? : InstanceUpdateOptions ) : Promise; - updateAttributes( keys : Object, options? : InstanceUpdateOptions ) : Promise; + update( key : string, value : any, options? : InstanceUpdateOptions ) : Promise; + update( keys : Object, options? : InstanceUpdateOptions ) : Promise; + updateAttributes( key : string, value : any, options? : InstanceUpdateOptions ) : Promise; + updateAttributes( keys : Object, options? : InstanceUpdateOptions ) : Promise; /** * Destroy the row corresponding to this instance. Depending on your setting for paranoid, the row will @@ -2847,7 +2847,7 @@ declare module "sequelize" { * If and object is provided, each column is incremented by the value given. */ increment( fields : string | string[] | Object, - options? : InstanceIncrementDecrementOptions ) : Promise; + options? : InstanceIncrementDecrementOptions ) : Promise; /** * Decrement the value of one or more columns. This is done in the database, which means it does not use @@ -2870,17 +2870,17 @@ declare module "sequelize" { * If and object is provided, each column is decremented by the value given */ decrement( fields : string | string[] | Object, - options? : InstanceIncrementDecrementOptions ) : Promise; + options? : InstanceIncrementDecrementOptions ) : Promise; /** * Check whether all values of this and `other` Instance are the same */ - equals( other : Instance ) : boolean; + equals( other : Instance ) : boolean; /** * Check if this is eqaul to one of `others` by calling equals */ - equalsOneOf( others : Instance[] ) : boolean; + equalsOneOf( others : Instance[] ) : boolean; /** * Convert the instance to a JSON representation. Proxies to calling `get` with no keys. This means get all @@ -3577,7 +3577,7 @@ declare module "sequelize" { * Sync this Model to the DB, that is create the table. Upon success, the callback will be called with the * model instance (this) */ - sync( options? : SyncOptions ) : Promise>; + sync( options? : SyncOptions ) : Promise; /** * Drop the table represented by this Model @@ -3595,7 +3595,7 @@ declare module "sequelize" { * @param schema The name of the schema * @param options */ - schema( schema : string, options? : SchemaOptions ) : Model; + schema( schema : string, options? : SchemaOptions ) : this; /** * Get the tablename of the model, taking schema into account. The method will return The name as a string @@ -3656,7 +3656,7 @@ declare module "sequelize" { * @return Model A reference to the model, with the scope(s) applied. Calling scope again on the returned * model will clear the previous scope. */ - scope( options? : string | string[] | ScopeOptions | WhereOptions ) : Model; + scope( options? : string | string[] | ScopeOptions | WhereOptions ) : this; /** * Search for multiple instances. @@ -3911,7 +3911,7 @@ declare module "sequelize" { /** * Unscope the model */ - unscoped() : Model; + unscoped() : this; } @@ -4089,7 +4089,7 @@ declare module "sequelize" { /** * Inserts a new record */ - insert( instance : Instance, tableName : string, values : Object, + insert( instance : Instance, tableName : string, values : Object, options? : QueryOptions ) : Promise; /** @@ -4107,7 +4107,7 @@ declare module "sequelize" { /** * Updates a row */ - update( instance : Instance, tableName : string, values : Object, identifier : Object, + update( instance : Instance, tableName : string, values : Object, identifier : Object, options? : QueryOptions ) : Promise; /** @@ -4119,7 +4119,7 @@ declare module "sequelize" { /** * Deletes a row */ - "delete"( instance : Instance, tableName : string, identifier : Object, + "delete"( instance : Instance, tableName : string, identifier : Object, options? : QueryOptions ) : Promise; /** @@ -4136,7 +4136,7 @@ declare module "sequelize" { /** * Increments a row value */ - increment( instance : Instance, tableName : string, values : Object, identifier : Object, + increment( instance : Instance, tableName : string, values : Object, identifier : Object, options? : QueryOptions ) : Promise; /** @@ -4482,7 +4482,7 @@ declare module "sequelize" { /** * A sequelize instance used to build the return instance */ - instance? : Instance; + instance? : Instance; /** * A sequelize model used to build the returned model instances (used to be called callee) @@ -5210,7 +5210,7 @@ declare module "sequelize" { /** * A reference to the sequelize instance class. */ - Instance : Instance; + Instance : Instance; /** * Creates a object representing a database function. This can be used in search queries, both in where and