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.

Model.where({}).update().exec() not updating

See original GitHub issue

Tried

yield Model
        .where('myId'),equals(id)
        .update({a:'1'})
        .exec()

and

yield Model
        .where({'myId':id})
        .update({a:'1'})  
        .exec()

both returns

 {ok:0,n:0,nModified:0}

However, the following works

yield Model.update(query,update,options).exec()

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
vkarpov15commented, Aug 3, 2015

Try

yield Model
        .find()
        .where('myId'),equals(id)
        .update({a:'1'})
        .exec()

Off the top of my head I don’t think Model even has a where() function, that’s on the query builder…

0reactions
vkarpov15commented, Nov 9, 2015

Yep the chained version should work in theory. I’ll investigate.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updated query inside EXEC not updating data? - Stack Overflow
I have used the "FROM USER U" in update query, But output generated by PRINT(@DynamicSql) if i copy and execute directly it executes...
Read more >
Pre update hook not updating field correctly #3549 - GitHub
Hey @willemmulder, only issue I can find with your code in #964 is that hashSync() takes 2 arguments re bcrypt docs. Other than...
Read more >
Update Data - UPDATE - SQLModel
Hey SQL database , I want to UPDATE the table called hero . ... Let's not forget to add that update_heroes() function to...
Read more >
UPDATE (Transact-SQL) - SQL Server - Microsoft Learn
When a FILESTREAM field is set to NULL, the BLOB data associated with the field is deleted. You cannot use .WRITE(), to perform...
Read more >
Updating Documents in Mongoose - Mastering JS
Using Model.updateOne() and Model.updateMany() , you can update the document without loading it from the database first. In the below 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