Add multiple Documents to the Firestore via a Map

Asked

Viewed 39 times

1

Hello. I have a firestore with the following structure:

bd: students: license plate dado1 dado2 dado3

Students is a collection, and each enrollment is a document. I have a hashmap of , where the string is the matricula, ie the name of the document. want to add these documents without a loop, just with a eating. what am I using:

db.collection("alunos").add(alunos.stream().collect(Collectors.toMap(Aluno::getMatricula, c -> c)));

however, when I look in my database the final result, it created:

students -> random id generated by it -> fields with (data:value).

I am structuring error the bd, or have how I make it work?

No answers

Browser other questions tagged

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