Hello,
I come back with a new question.
With my android application, I call a function (Delete_Article_In_Fridge). This function have to find and delete an object (0, 1, 2 …) in an Array (called Fridge) inside a collection (customer).
Inside the customer collection.
Of course I arrive to call my fonction with 2 arguments (email account, id object). But i don’t find how to search the id in the arrayn which means say to the function search the object x inside the array Fridge.
Does anyone have an idea ?
Thank’s in advance.
Your function will need to be passes the name of the product you want to remove, together with either the _id
or the email
of the users. You should then be able to use the $pull
operator on your fridge
array: https://docs.mongodb.com/manual/reference/operator/update/pull/
Note that findOneAndDelete
would remove the entire user document.
Hi Andrew,
Thanks for your answer and your time.
While I was reading your answer, I understood that I was probably not so clear.
I would like to use a function from realm web site.
An example :
I guess pull function doesn’t exist cause I didn’t find it.
Is it exact ?
Hello,
After make research … and trying to understand your answer (which is completely correct), I found the answer.
const update = {
$pull:
{"fridge": {
"product": product,
"expirationDate": expDate
}
}
};
Thank you.