My database is like this:
I'm trying to the for example "Ricardo Meireles" with the following code:
const getTarefasFuncionario = async () => {
setTarefasFuncionario([]);
const q = query(
collection(db, "tarefas"),
where("funcionarios", "array-contains", {
photoURL: currentUser.photoURL,
value: currentUser.displayName,
})
);
const querySnapshot = await getDocs(q);
const tarefas = [];
querySnapshot.forEach((doc) => {
tarefas.push({ ...doc.data() });
console.log(doc.data());
});
tarefas.forEach((tarefa) => {
const data = tarefa.dia.toDate();
const options = { day: "2-digit", month: "2-digit", year: "numeric" };
tarefa.dia = data.toLocaleDateString("pt-BR", options);
});
setTarefasFuncionario(tarefas);
};
But its not getting anything, I tried to use the firebase query system like this:
But it also did not work, what am I doing wrong?
I'm expecting a an array of "tarefas" that contains the user as a "funcionario"