I need to write a simple collection where documents only contain an array list of strings.
usersBlocked
-blockerID
- usersBlockedList
-userID1
-....
-userIDN
At this moment I'm able to update the list if the document already exist in this way: (for testing porpouses I wrote it by hand).
val reference = Firebase.firestore
.collection("usersBlocked")
.document(userIDBlocker)
reference.update("usersBlocked", FieldValue.arrayUnion(userIDToBlock))
.addOnSuccessListener { Logger.d("Blocked") }
.addOnFailureListener { Logger.d(it.localizedMessage) }
As I said, if the document exists, the update is correct, but when there is no document... I'm getting this error:
NOT_FOUND: No document to update: projects/xxxxxx/databases/(default)/documents/usersBlocked/2oLOYbG2z9gRC5VugchEP7ZPpy53
I assume that obviously not exist, but I don't know how to write Arrays in a document.
I saw how to save Maps, but is not what I need.
DB Structure:
