Solution for Firestore error ‘Requested Entity not found’ in swift app
is Given Below:
I’m getting this error:
[Firebase/Firestore][I-FST000001] WriteStream (129e2dd38) Stream error: 'Not found: Requested entity was not found.'
in my app built on SwiftUI and i cannot seem to find any information relating to this error and firestore.
for context: this is an app for a dog walker, Dogs have a many-to-many relationship with Customers. this particular bit of code is supposed to add a list of DocumentID’s from the dogs
collection
when a dog is added to Firestore, a Dog
object is added to a Customer.dogs
and then this function is called, passing in the Customer
in quesiton
func saveDogsTo(_ customer: Customer){
let db = Firestore.firestore()
print("saveing listed dogs to (customer.id)")
var ids: [String] = [String]()
for dog in customer.dogs{
print("Appending id: (dog.id)")
ids.append(dog.id!)
}
db.collection("customer").document(customer.id!).updateData(["dogs": ids])
}
The print statements are showing the correct information, all the ID’s exist on Firestore (I’ve checked), and this is not down to dogs
being missing from a customer’s document (only cause i could think of, but i tried running this code on documents with and without existing dogs
fields)
I’m at a dead end here so can anybody see my mistake?
Happy to provide any extra information as required. Just ask 🙂
Thanks
For the benefit of anyone else with a similar error.
I was trying to update a document in the customer
collection, however the collection was actually called customers
meaning Firestore was looking in the wrong place for the document
Anybody else with this error should check all their collection references are spelled correctly -_-