question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

order inside findOrCreate

See original GitHub issue

This does not work:

    Purchase.scope(scope).findOrCreate({
      where: {
        referenceId: 5,
      },
      order: [["updatedAt", "DESC"]],
    });

The typescript error:

Argument of type '{ where: { referenceId: number; }; order: string[][]; }' is not assignable to parameter of type 'FindOrCreateOptions'.
  Object literal may only specify known properties, and 'order' does not exist in type 'FindOrCreateOptions'.ts(2345)

Environment

sequelize-typescript: 1.0.0-beta.3 Dialect:

  • mysql
  • [ X ] postgres
  • sqlite
  • mssql
  • any Dialect library version: pg version 6.4.2 Database version: 9.6.12 Sequelize version: 5.8.10 Node Version: 8.11.4 OS: macOS 10.14.3 TypeScript version: 3.4.3 (or 3.3.3 same issue) Tested with latest release:
  • No
  • [ X ] Yes, specify that version: 5.8.10

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

How to use findOrCreate in Sequelize - Stack Overflow
In order to avoid this, I would like to do a process to update the database only when the specified userid does not...
Read more >
Model Querying - Finders - Sequelize
The method findOrCreate will create an entry in the table unless it can find one fulfilling the query options. In both cases, it...
Read more >
.findOrCreate() - Sails.js
This particular criteria should always match exactly zero or one records in the database. 2, initialValues, Dictionary, The initial values for the new...
Read more >
need help figuring out why a sequelize findOrCreate(...) works ...
Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, ...
Read more >
Model usage - Manual | Sequelize
The method findOrCreate can be used to check if a certain element already exists in the ... In order to do that you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found