Closed thatfiredev closed 2 years ago
I've noticed how this app is using UUID.randomUUID().toString() to generate a document ID and save it on Firestore: https://github.com/FirebaseExtended/make-it-so-android/blob/40e46da8b587f0466e08a051a41d67c7088083f2/app/src/main/java/com/example/makeitso/model/service/impl/StorageServiceImpl.kt#L69-L73
UUID.randomUUID().toString()
It would be nice to demonstrate Firestore's auto-generated ids instead:
Firebase.firestore .collection(TASK_COLLECTION) .add(task) .addOnCompleteListener { onResult(it.exception) }
And when reading the tasks, we'd manually set the id:
value?.documentChanges?.forEach { val wasDocumentDeleted = it.type == REMOVED val task = it.document.toObject<Task>().apply { task.id = it.document.id } onDocumentEvent(wasDocumentDeleted, task) }
Fixed by: https://github.com/FirebaseExtended/make-it-so-android/pull/9
I've noticed how this app is using
UUID.randomUUID().toString()
to generate a document ID and save it on Firestore: https://github.com/FirebaseExtended/make-it-so-android/blob/40e46da8b587f0466e08a051a41d67c7088083f2/app/src/main/java/com/example/makeitso/model/service/impl/StorageServiceImpl.kt#L69-L73It would be nice to demonstrate Firestore's auto-generated ids instead:
And when reading the tasks, we'd manually set the id: