Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add missing fields to 'FindOrCreateType' #12338

Merged
merged 2 commits into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions types/lib/model.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,12 +685,11 @@ export interface Hookable {
/**
* Options for Model.findOrCreate method
*/
export interface FindOrCreateOptions extends Logging, Transactionable {
export interface FindOrCreateOptions extends Filterable, Logging, Transactionable {
/**
* A hash of search attributes.
* The fields to insert / update. Defaults to all fields
*/
where: WhereOptions;

fields?: string[];
/**
* Default values to use if building a new instance
*/
Expand Down
20 changes: 17 additions & 3 deletions types/test/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ UserModel.findCreateFind({
}
})

/**
* Tests for findCreateFind() type.
sushantdhiman marked this conversation as resolved.
Show resolved Hide resolved
*/

UserModel.findOrCreate({
fields: [ "jane.doe" ],
where: {
username: "jane.doe"
},
defaults: {
username: "jane.doe"
}
})

/**
* Test for primaryKeyAttributes.
*/
Expand All @@ -116,12 +130,12 @@ someInstance.getOthers({
joinTableAttributes: { include: [ 'id' ] }
})

/**
/**
* Test for through options in creating a BelongsToMany association
*/
class Film extends Model {}

class Actor extends Model {}
class Actor extends Model {}

Film.belongsToMany(Actor, {
through: {
Expand All @@ -135,4 +149,4 @@ Actor.belongsToMany(Film, {
model: 'FilmActors',
paranoid: true
}
})
})