read24 - Server: Data Objects

July 3, 2020

Roger Ngo

With the development environment set up, I am ready to to go! The next easiest thing to tackle is to create the TypeScript interfaces for the data model.

I don't need a database yet. I plan to mock the data for now, but I would like to make the object representations in code. To do that, I will create TypeScript interface definitions for the possible entities in the read24 system.

First, create a models folder under src. Each object interface will be stored here. For example, the Student object is defined like this in student.ts:

export interface Student {
    id: number;
    classroomId: number;
    firstName: string;
    middleName: string;
    lastName: string;
    grade: number;
    userId: number;
};

So, pretty much all the other objects will be defined in this pattern.

I have tried to make this as simple as possible. For all the objects which refer to another, for example, an object which represents a JOIN, I have just left the references as ID values. For now, I am avoiding any over complication, so no references to other objects will be needed until I am sure I will be using it.

Yes, QuizQuestion is like:

export interface QuizQuestion {
    id: number;
    quizToken: string;
    questionId: number;
};

When it can be:

export interface QuizQuestion {
    id: number;
    quizToken: QuizToken;
    question: Question;
};

I will work with what I have now, and of course, can extend all this later to add more complexity for convenience.