With cloud firestore, you can convert a document to your object with document.toObject(YourClass.class);
where the class's variables match those in your database. However, if one of the variables in the database is a reference, which data type would you use in the java class? Note that I need to not only store it in my data model but retrieve it and set it with the override methods of the form:
protected MyDataModel(Parcel in) {
mString = in.readString();
}
and
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(mString);
}
If I use a DocumentReference, then in writeToParcel(), how would I write it? Also, how would I read it in the protected Parcel in
constructor? I have tried writeSerializable()
and readSerializable()
but DocumentReference
does not implement Serializable
.
from Firebase toObject with ref
No comments:
Post a Comment