» Node.js: Build a REST API with Express » 2. Development » 2.3 Data Models

Data Models

Data models represent the structure of the data that the API deals with. These models define the shape of the data entities exchanged between the client and the server.

For example, in this books management api project, a Book model can be defined:

Create src/model/book.ts:

// Book represents the structure of a book
export interface Book {
  id: number;
  title: string;
  author: string;
  published_at: string;
  description: string;
  isbn: string;
  total_pages: number;
  created_at: Date;
  updated_at: Date;
}