I'm trying to minimize the amount of data I have in my database.
I have a class called user which looks like the following:
class User {
private Position pos;
private String uid;}
Right now my database looks like:
uid{
pos{ L1=value,
L2=value
}
uid=value
}
Very minimized, in fact I'd prefer not even to have the additional uid because the key is the uid which is the unique identifier anyways.
Now, I want to add an additional variable called working into the class.
class User{
private Position pos;
private String uid;
private boolean working;
}
Using ref.setValue(User), the database now becomes this:
uid{
pos{ L1=value,
L2=value
}
uid=value,
working=value
}
I do not need to store the working variable in the database, that's just needless information to send. How do I not send this over, but keep it in my User class? The same goes for the additional String uid. I would prefer to remove that from the database as well, but keep it in the class.
Check out the @Exclude
and IgnoreExtraProperties
.
https://firebase.google.com/docs/reference/android/com/google/firebase/database/Exclude
class User{
private Position pos;
private String uid;
@Exclude
private boolean working;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With