I want to distinguish between deleted and data that was first created. I´m using the code from Firebase:
if (event.data.previous.exists()) {
return;
}
// Exit when the data is deleted.
if (!event.data.exists()) {
return;
}
However, it doesn't work. I´m listening to the database which is structured as following:
- in use
- fruitID
- id: fruitID
I want to use code when the data is deleted and another code when the data is created, so when a fruit is added.
Using the given code only the part in
if (event.data.previous.exists()){
}
is executed AND ALWAYS when the data is DELETED.
Any suggestions?
Thanks.
via ktm125
No comments:
Post a Comment