I am getting an error "Cannot convert value of type '()' to expected argument type '[String : Any]'". I am trying to add data as a Codable struct to submit to firebase. However this error keeps popping up. Here is my code (in swift).
do {
try db.collection("users").document("i").setData(user)
} catch {
print(error)
}
Here is the struct:
public struct User: Codable {
var id: String
var first_name: String
var last_name: String
var email: String
enum CodingKeys: String, CodingKey {
case id
case first_name
case last_name
case email
}
}
I have a feeling I am misunderstanding Codable but I am following tutorials exactly. I tried replacing user with ["user": user] nut that just crashes the app. Please help! I am following the firebase website example https://firebase.google.com/docs/firestore/manage-data/add-data