I have been adding POJOs to Firestore that automatically interprets them as JSON objects for the database. However I want to have one of my POJOs have what Firestore calls a reference type. Would the attribute type just be DocumentReference instead of a String?
I'm working on an Android project using Java.
Here is the custom object example from the Firebase Docs.
public class City {
private String name;
private String state;
private String country;
private boolean capital;
private long population;
private List<String> regions;
public City() {}
public City(String name, String state, String country, boolean capital, long population, List<String> regions) {
// ...
}
public String getName() {
return name;
}
public String getState() {
return state;
}
public String getCountry() {
return country;
}
public boolean isCapital() {
return capital;
}
public long getPopulation() {
return population;
}
public List<String> getRegions() {
return regions;
}
}
Then to add to the database
City city = new City("Los Angeles", "CA", "USA",
false, 5000000L, Arrays.asList("west_coast", "sorcal"));
db.collection("cities").document("LA").set(city);