TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

How to access firestore's FieldPath.DocumentId()? #105

Closed AdamBebko closed 1 year ago

AdamBebko commented 1 year ago

I'm looking to filter a query by documentID, but I can't seem to find a way to access FieldPath.DocumentId(). I can see it exists in the native plugins, but it doesn't seem to be accessible from CrossFirebaseFirestore

Any ideas on this? I thought of using platform specific code to return the path, but it didn't work because the method returns a FieldPath object, rather than a string or something interchangeable.

Any ideas on how this might be possible?

TobiasBuchholz commented 1 year ago

Hmm, actually there is a DocumentId() method on the plugins shared FieldPath class, so you can just use it in a query like this:

var pokemons = await sut
    .GetCollection("pokemons")
    .WhereFieldIn(FieldPath.DocumentId(), new object[] { "1", "2", "3" })
    .GetDocumentsAsync<Pokemon>();