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.

How to know 'create'and'update' result?

See original GitHub issue

like this

  let result = await User.update(
    {name : 'shjhkj' },
    {
      where: {id: id}
    });

how to use the result to know update/create is successful or fail?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sushantdhimancommented, Aug 9, 2016

Do you realize every function in Sequelize Public API returns a Promise, on which you can add .then or .catch ? Make sure you understand what Promise and Async/await are.

In ES7, async function also return Promise, you can add .then . catch on them too, otherwise you can warp await statement with try/catch

0reactions
eseligercommented, Mar 2, 2018

@jehnsen why are you passing 3 arguments to upsert? see here for correct syntax and feel free to refer to stackoverfow os sequelize slack for help on programming: http://docs.sequelizejs.com/class/lib/model.js~Model.html#static-method-upsert

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create and run an update query - Microsoft Support
Step 1: Create a select query to identify the records to update · On the Design tab, in the Results group, click Run....
Read more >
Sequelize - update record, and return result - Stack Overflow
Assuming you are using Postgres, you can access the updated object with result[1].dataValues . You must set returning: true option to tell ......
Read more >
Update Queries - CustomGuide
1. Click the Create tab on the ribbon. 2. Click the Query Design button. The Query Design window and Show Table dialog box...
Read more >
Mutations in Apollo Client - Apollo GraphQL Docs
This article demonstrates how to send updates to your GraphQL server with the useMutation hook. You'll also learn how to update the Apollo...
Read more >
Updating Table and values in SQL - Intellipaat
In this section of the SQL tutorial, you will learn what exactly an 'UPDATE' query does along with its syntax and an example....
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