Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetOptions needs IfMatch #7470

Closed
lukepuplett opened this issue Nov 9, 2021 · 4 comments
Closed

SetOptions needs IfMatch #7470

lukepuplett opened this issue Nov 9, 2021 · 4 comments

Comments

@lukepuplett
Copy link

lukepuplett commented Nov 9, 2021

Is your feature request related to a problem? Please describe.

I'm researching GCP products for a move from Azure. My code assumes ETags/row-versions are a thing generally when persisting data, i.e. that the concept is transferrable across products in software engineering. I see that Firestore's REST API returns an ETag and supports conditional requests via if-match.

However, I cannot see this functionality surfaced via the .NET C# library. I have checked the SetOptions and Precondition classes but nothing; it seems LastUpdateTime is the only option.

Note - I assume the current last update time is made available easily in the document when it's read, so I can easily use it in the subsequent update. If not, then that's a feature request.

Note - I assume the current ETag is also made available easily in the document when it's read. If not, then that too is a feature request.

I regard conditional updates based on unique version to be a critical feature of any database. I also think these values play an important role in distributed architectures and microservices where services maintain their own copies of data from remote services; the ETag of the remote data is critical for failing local conditional updates. It's complicated, but trust me.

Describe the solution you'd like

I'd like Precondition.IfMatch and/or SetOptions.IfMatch available.

Describe alternatives you've considered

Noting my assumption above, the alternative is a far more invasive refactor of my code, which risks making it incompatible with other stores that use ETags/row-versions.

Else I could add a row-version field to all my documents but this would need a findAndModify sort of method like that found in MongoDB, or an update ... where in T-SQL.

Additional context

Functionality exposed in REST API.

https://firebase.google.com/docs/reference/rest/database#section-cond-ifmatch

Blog, announcement, fanfare, 4 years ago.

https://firebase.googleblog.com/2017/07/introducing-conditional-rest-requests.html

@jskeet
Copy link
Collaborator

jskeet commented Nov 9, 2021

Just to check, all of this is about the Firestore libraries, right? (This repository is the home of over 100 libraries.) Note that the library can only expose what's in the underlying gRPC API, and I don't think what you're asking for is in the underlying API.

The last update time is available when you read a document, yes - so I'd expect to use Precondition.LastUpdateTime rather than an etag, basically.

I would suggest that this is probably something to describe with the Firestore team directly rather than here, as it's an API feature request rather than being specific to the .NET client library.

@lukepuplett
Copy link
Author

Oh hey Jon, sorry yes: Firestore libraries it is. I didn't realise it's gRPC underneath. I'll have a look and see if I can find the Firestore team on here. Thanks for the prompt answer.

@lukepuplett
Copy link
Author

Okay I've found a form through which I can submit a feature request. I'll do that.

Close this if you think we're done.

@jskeet
Copy link
Collaborator

jskeet commented Nov 9, 2021

Yup, thanks. Obviously if it gets exposed, we'll implement it in the C# library :)

@jskeet jskeet closed this as completed Nov 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants