How to always register data in the last generated Event?

Asked

Viewed 58 times

2

In my code every time I perform a criminal record a document is created. I wonder if you have how to register information in the latter document generated instead of generating another. I’m doing it in Java, using the Cloud Firestore.

  db.collection("enfermeiros").document()
                            .set(enfermeiro, SetOptions.merge())
                            .addOnSuccessListener(new OnSuccessListener<Void>() {
                                @Override
                                public void onSuccess(Void aVoid) {
                                    Log.d(TAG, "DEU BOM");
                                }
                            })
                            .addOnFailureListener(new OnFailureListener() {
                                @Override
                                public void onFailure(@NonNull Exception e) {
                                    Log.w(TAG, "DEU MERDA", e);
                                }
                            });

1 answer

1

I do so:

firestoreMetas
.collection("metas_compras")
.document(metaCompra.id_meta)
.set(metaCompra)
.addOnSuccessListener {
    //Sucesso 
}.addOnFailureListener{
    //Erro
}

Well, basically, I use the id of Document (goals) I want, and pass an object (metaCompra) with the new information.

I hope I’ve helped...

  • The way you suggested the information will be registered in a specific id(In the ID you want )?

  • That, as I understand it, you don’t want to create a new Ocument, you want to save the information in what is already created right? Then, you use the Id of what is created and save the new information in it.

  • in fact what I wanted was to create a Document and register in it and repeat the process every time I make a registration, each time in a different Document.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.