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.

Save document should return True on update

See original GitHub issue

As mentioned in docs update method should only be used for partial update, for full update save method should be used, but save method checks only a created field of ES response so it returns False on a successful full update of a document.

An example of ES response that causes the problem: {"_index":"indexnam","_type":"typename","_id":"randomid","_version":3,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"created":false}

Elasticsearch version (docker-elk):

"version" : {
    "number" : "5.4.2",
    "build_hash" : "929b078",
    "build_date" : "2017-06-15T02:29:28.122Z",
    "build_snapshot" : false,
    "lucene_version" : "6.5.1"
  }

Library version: 5.3.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
honzakralcommented, Aug 10, 2017

Thanks for the feedback, I appreciate it. I know this part is confusing to people (and for very good reason).

1reaction
honzakralcommented, Aug 10, 2017

If there is no exception it means it was successful, no need to check for anything.

Sorry for the confusion, by that sentence I meant return True if document was created and return False if updated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel save() method returning true but not updating records
This will return true. Save always returns true, unless update or save did not succeed (because user_id is not found or something like...
Read more >
Mongoose v6.8.0: API docs
isObjectIdOrHexString() returns true only for ObjectId instances or 24 character hex strings, and will return false for numbers, documents, and strings of ...
Read more >
Making decisions in your code — conditionals - MDN Web Docs
In this snippet, if the OR statement returns true , the NOT operator will negate it so that the overall expression returns false...
Read more >
Upsert in MongoDB - GeeksforGeeks
If the value of this option is set to true and the document or documents found that match the specified query, then the...
Read more >
Collections | Meteor API Docs
Increasing this will save CPU and mongo load at the expense of slower ... The number of affected documents will be returned from...
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