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.

Any plan on Upserting ?

See original GitHub issue

Do you plan on adding upserting methods like in MongoDB ? Like in this example :

Foo foo = ...
var replaceOneResult = await collection.ReplaceOneAsync(
    doc => doc.Id == foo.Id, 
    foo, 
    new UpdateOptions {IsUpsert = true});

Much thanks for this useful library.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
mamidoncommented, May 7, 2016

Just adding my 👍 to this request; it’s a really useful feature when designing idempotent workloads.

My current ‘workaround’ (which is really more of pretty code than efficient): collection.InsertBulk(documentsToUpsert.Where(d => !collection.Update(d)).ToList());

2reactions
Dessixcommented, Jan 2, 2016

I’ve been working with a basic extension method to take the place of this behaviour until such a time when it is truly available. Here’s a simple implementation which relies on the type having an ID field that LiteDB can map correctly, or a mapping entry for the type in question that handles keying said objects. If the keys are equal, the item will be upserted. In short, it’s really an Update call followed by an Insert call on failure, but it works for me in cases where performance aren’t super critical. Implementation available here

Read more comments on GitHub >

github_iconTop Results From Across the Web

any plan of implementing 'UPSERT' or 'ON DUPLICATE ...
sql: any plan of implementing 'UPSERT' or 'ON DUPLICATE KEY UPDATE' ? #1962 ... Postgresql has its own implementation of "Upsert".
Read more >
Upserting objects in Apex: can I assert which have been ...
I'm upserting a list of custom objects in an Apex controller that are retrieved on demand from an external source. My object has...
Read more >
Upserting Records | Apex Developer Guide
Using the upsert operation, you can either insert or update an existing record ... a task for the owner(s) of any leads that...
Read more >
UPSERT
The UPSERT statement inserts rows when values do not violate uniqueness constraints, and it updates rows when values do violate uniqueness constraints.
Read more >
Elasticsearch Upsert: Performing Upsert Operations, with ...
In Elasticsearch, upsert is a powerful operation that allows you to perform both update and insert actions in a single request.
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