Skip to content

postgrelize / FindOrCreateOptions

Type Alias: FindOrCreateOptions<T> ​

FindOrCreateOptions<T> = FindOptions<T> & Readonly<{ defaults?: Partial<T>; }>

Defined in: src/model/find-options.ts:205

Options of findOrCreate and findOrBuild.

Extends FindOptions; the where values are also used when creating the row.

Type Parameters ​

T ​

T = Values

See ​

Model.findOrCreate

Example ​

ts
const [user, created] = await User.findOrCreate({
  where: { email: 'a@example.com' },
  defaults: { name: 'Ann' },
});

Released under the MIT License.