不要怂,就是干,撸起袖子干!

Commit 72925cf7 by Marquitos Committed by GitHub

fix: add missing fields to 'FindOrCreateType' (#12338)

1 parent f3671912
Showing with 20 additions and 8 deletions
...@@ -685,12 +685,11 @@ export interface Hookable { ...@@ -685,12 +685,11 @@ export interface Hookable {
/** /**
* Options for Model.findOrCreate method * 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 * Default values to use if building a new instance
*/ */
......
...@@ -99,6 +99,20 @@ UserModel.findCreateFind({ ...@@ -99,6 +99,20 @@ UserModel.findCreateFind({
}) })
/** /**
* Tests for findOrCreate() type.
*/
UserModel.findOrCreate({
fields: [ "jane.doe" ],
where: {
username: "jane.doe"
},
defaults: {
username: "jane.doe"
}
})
/**
* Test for primaryKeyAttributes. * Test for primaryKeyAttributes.
*/ */
class TestModel extends Model {}; class TestModel extends Model {};
...@@ -116,12 +130,12 @@ someInstance.getOthers({ ...@@ -116,12 +130,12 @@ someInstance.getOthers({
joinTableAttributes: { include: [ 'id' ] } joinTableAttributes: { include: [ 'id' ] }
}) })
/** /**
* Test for through options in creating a BelongsToMany association * Test for through options in creating a BelongsToMany association
*/ */
class Film extends Model {} class Film extends Model {}
class Actor extends Model {} class Actor extends Model {}
Film.belongsToMany(Actor, { Film.belongsToMany(Actor, {
through: { through: {
...@@ -135,4 +149,4 @@ Actor.belongsToMany(Film, { ...@@ -135,4 +149,4 @@ Actor.belongsToMany(Film, {
model: 'FilmActors', model: 'FilmActors',
paranoid: true paranoid: true
} }
}) })
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!