Closed Darkhero789 closed 5 months ago
Hm, that is very weird. I would expect at least delete to work.
According to the Test Harness that we've implemented, which you can find here, for the delete task, you should try awaiting the delete_document signal instead of task_finished. It will return a true false value to you that will say whether or not the document was successfully deleted. I'd also connect to task_error on the task, to see if an error is being thrown. You can see these different signals here: https://github.com/GodotNuts/GodotFirebase/blob/4.x/addons/godot-firebase/firestore/firestore_task.gd#L26
ok. So that corrected the issue with firestore_collection.delete("DOCUMENT_ID"). However i realize now that delete() wasn't what i was looking for. Apologies. I'm trying to delete a single document field from a document. So if you could point me in the direction of where i should look to figure that out I'd be very grateful.
I think for that, it may be the case that you can do one of two things: put the document into memory for your app, delete it from Firestore, remove the field, then upload it with the same name as if it was the same document, or you can look into seeing if _merge_dict has a bug that accidentally merges those values back into the document after coming back. Here's where you'd look for that: https://github.com/GodotNuts/GodotFirebase/blob/4.x/addons/godot-firebase/firestore/firestore_task.gd#L180
One thing you might also try is when completing your update, instead of awaiting task_finished again, try awaiting update_document. This is after you remove the value from the dictionary and then call update with that as the payload.
Okay, I've looked into this and added a test case for our test harness. Deleting an item is not properly working. I will attempt to fix this today, along with a few other things. I'll leave this open until I've fixed it.
Alright, I have fixed this with the most recent #399 pull request, so I'm closing this for now. The Asset Store may take a minute to be updated, but GitHub itself has the latest.
To remove a field from your document now, just call document.remove_field("field_name")
. This only works at the root level for now, but when you do that and call update, it will correctly remove the field from the document.
Describe the bug I have this line of code var task: FirestoreTask = collection.update(auth.localid, data) with data being a dictionary with data for multiple objects. My issue is that when i delete one of the objects and click save, it doesn't erase the object from the database. Instead if i logout of my program and log back it the erased object is back. My best guess is that update is seeing it's missing from the dictionary i'm saving and the database then merging them so that what i removed is still there.
I've looked into the wiki page trying to find something that might work but every route i look trying to figure it out is out of date from what i see.
Tried var del_task: FirestoreTask = firestore_collection.delete("DOCUMENT_ID") var document = await del_task.task_finished and it did nothing for the database. Never got an error message for it so i guess it worked but it didn't send to the database.
It's not a bug more so as i'm trying to figure out how to delete a single object from the files and i'm not seeing how to do that other then completely erasing the data by saving a empty dictionary, which weirdly enough to me, works without issue. Then saving the data in the application.
To Reproduce Not a bug, unless update is supposed to remove an object if not present or firetask delete is supposed to go to the database.
Expected behavior A clear and concise description of what you expected to happen, for example:
Environment: