Thanks for having a look not sure what I am missing?
Here is what my data looks like in Firestore
Here is Comment Model. Note I should have shown this in original question for more context.
import SwiftUI
import FirebaseFirestoreSwift
struct Comment: Identifiable, Codable, Hashable {
var id: String
var userId: String
var storyId: String
var commentText: String
var createdAt: Date
}
Here is method where I am deleting Firestore data. No error is being thrown? The print statements in method print the expected firestore document id and the whole comment object in question But it also prints the success case and nothing changes in UI or FireStore.
func deleteComment(id: String, comment: Comment) {
print(id, comment)
//prints firestore document id and whole comment object
let commentData: [String: Any] = [
"id" : comment.id as Any,
"userId" : comment.userId,
"storyId" : comment.storyId,
"commentText" : comment.commentText,
"createdAt" : comment.createdAt
]
store.collection(path).document(id).updateData([
"comments" : FieldValue.arrayRemove([commentData])
]) { error in
if let error = error {
print("Unable to delete comment: \(error.localizedDescription)")
} else {
print("Successfully deleted comment")
}
}
}

s) in your first example and "comments` (with ans) in your second one.arrayRemoveneeds the whole object passed to it -- you're only passing theid.