You see I have a multidimensional array and I need to remove a field from that array but I can not get it.
I must clarify that I am using firestore firestore.
That's my code:
db.collection("database").doc("users").get().then(data => {
var arrs = data.users;
var remove = [{ name: "Juan" }, { name: "Alex" }]; // Este valor lo obtengo dependiendo de los checkbox's seleccionados
var newArr = [];
for (var i = 0; i < arrs.length; i++) {
var index = arrs[i].indexOf(remove);
if (index !== -1) {
newArr.push(data.users.splice(i, 0));
}
}
db.doc("database/users").update({
users: newArr
});
});
This is the JSON that returns to me when I make the list of users:
{
"users": [{
"name": "Juan"
"ave": 23
}, {
"name": "Alex",
"age": 17
}, {
"name": "Josefina",
"age": 18
}, {
"name": "Carla",
"age": 25
}]
}
What I was supposed to return to me when I removed the indicated fields would be this:
{
"users": [{
"name": "Josefina",
"age": 18
}, {
"name": "Carla",
"age": 25
}]
}
I need help, it took more than 2hrs trying to find a solution. Thank you very much