Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#14588 from zaggino/sequelize/paran…
Browse files Browse the repository at this point in the history
…oid-2

fix FindOrInitializeOptions and FindCreateFindOptions
  • Loading branch information
zhengbli authored Feb 14, 2017
2 parents 9cddec2 + 01a2d0e commit 4f17805
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
23 changes: 5 additions & 18 deletions sequelize/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3319,38 +3319,25 @@ declare namespace sequelize {
/**
* Options for Model.findOrInitialize method
*/
interface FindOrInitializeOptions<TAttributes> extends LoggingOptions {

/**
* A hash of search attributes.
*/
where: string | WhereOptions;
interface FindOrInitializeOptions<TAttributes> extends FindOptions {

/**
* Default values to use if building a new instance
*/
defaults?: TAttributes;

/**
* Transaction to run query under
*/
transaction?: Transaction;
}

/**
* Options for Model.findOrInitialize method
* Options for Model.findOrInitialize method
*/
interface FindCreateFindOptions<TAttributes> {
interface FindCreateFindOptions<TAttributes> extends FindOptions {

/**
* A hash of search attributes.
*/
where: string | WhereOptions;

/**
* Default values to use if building a new instance
* Default values to use if building a new instance
*/
defaults?: TAttributes;

}

/**
Expand Down
2 changes: 1 addition & 1 deletion sequelize/sequelize-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,7 @@ let findOrRetVal: Promise<[AnyInstance, boolean]>;
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' } } );
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' }, transaction : t } );
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' }, defaults : { foo : 'asd' }, transaction : t } );
findOrRetVal = User.findOrInitialize( { where : { username : 'foo' }, defaults : { foo : 'asd' }, paranoid : false } );

findOrRetVal = User.findOrCreate( { where : { a : 'b' }, defaults : { json : { a : { b : 'c' }, d : [1, 2, 3] } } } );
findOrRetVal = User.findOrCreate( { where : { a : 'b' }, defaults : { json : 'a', data : 'b' } } );
Expand All @@ -989,7 +990,6 @@ findOrRetVal = User.findOrCreate( { where : { objectId : 'asdasdasd' }, defaults
findOrRetVal = User.findOrCreate( { where : { id : undefined }, defaults : { name : Math.random().toString() } } );
findOrRetVal = User.findOrCreate( { where : { email : 'unique.email.@d.com', companyId : Math.floor( Math.random() * 5 ) } } );
findOrRetVal = User.findOrCreate( { where : { objectId : 1 }, defaults : { bool : false } } );
findOrRetVal = User.findOrCreate( { where : 'c', defaults : {} } );

User.upsert( { id : 42, username : 'doe', foo : s.fn( 'upper', 'mixedCase2' ) } );

Expand Down

0 comments on commit 4f17805

Please sign in to comment.