在云端防火墙中存储复杂的数据模型

时间:2018-03-18 16:11:45

标签: java android firebase firebase-realtime-database google-cloud-firestore

我知道这是一个愚蠢的问题,但请帮忙。

我有三个模型类

学生班

public class Student {
    private String department;
    private String year;
    private String division;
    private String batch;
    private Timetable timetable;

    public Student() {}

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getDivision() {
        return division;
    }

    public void setDivision(String division) {
        this.division = division;
    }

    public String getBatch() {
        return batch;
    }

    public void setBatch(String batch) {
        this.batch = batch;
    }

    public Timetable getTimetable() {
        return timetable;
    }

    public void setTimetable(Timetable timetable) {
        this.timetable = timetable;
    }
}

时间表课程

public class Timetable implements Parcelable {
    private String day;
    private List<Lecture> lectures;

    public Timetable(String day, List<Lecture> lectures) {
        this.day = day;
        this.lectures = lectures;
    }

    public String getDay() {
        return day;
    }

    public void setDay(String day) {
        this.day = day;
    }

    public List<Lecture> getLectures() {
        return lectures;
    }

    public void setLectures(List<Lecture> lectures) {
        this.lectures = lectures;
    }
}

讲座课程

public class Lecture implements Parcelable {
    private String code;
    private String professorCode;
    private String room;
    private long startTime;
    private long endTime;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getProfessorCode() {
        return professorCode;
    }

    public void setProfessorCode(String professorCode) {
        this.professorCode = professorCode;
    }

    public String getRoom() {
        return room;
    }

    public void setRoom(String room) {
        this.room = room;
    }

    public long getStartTime() {
        return startTime;
    }

    public void setStartTime(long startTime) {
        this.startTime = startTime;
    }

    public long getEndTime() {
        return endTime;
    }

    public void setEndTime(long endTime) {
        this.endTime = endTime;
    }

}

现在,由于我的数据模型中存在嵌套包含,因此我无法在Firebase Cloud Firestore中构建数据。

  

学生有部门,年级,部门,时间表。   时间表包含日期和讲座列表。   讲座有代码,professorCode,room,startTime,endTime

如果有人帮助在集合和文档方面在firestore中构建此数据,那将会非常棒。我是Firestore的新手,我发现收藏和文件很难。 我本来可以使用实时数据库,但是有一些问题所以我只能使用Firestore。

提前致谢

0 个答案:

没有答案