File

src/app/book/book-data/models/book.model.ts

Implements

BookInterface

Index

Properties
Methods

Constructor

constructor(id: number, isbn: string, title?: string, author?: string, genre?: string, summary?: string, description?: string, released?: Date, cover?: literal type, authors?: literal type[])
Parameters :
Name Type Optional
id number No
isbn string No
title string Yes
author string Yes
genre string Yes
summary string Yes
description string Yes
released Date Yes
cover literal type Yes
authors literal type[] Yes

Properties

Public Optional author
Type : string
Public Optional authors
Type : literal type[]
Public Optional cover
Type : literal type
Public Optional description
Type : string
Public Optional genre
Type : string
Public id
Type : number
Public isbn
Type : string
Public Optional released
Type : Date
Public Optional summary
Type : string
Public Optional title
Type : string

Methods

Static fromJson
fromJson(json: Partial)
Parameters :
Name Type Optional
json Partial<Book> No
Returns : Book
export interface BookInterface {
  id: number
  isbn: string
  title?: string
  author?: string
  genre?: string
  summary?: string
  description?: string
  released?: Date
  cover?: {small: string, medium: string, large: string}
  authors?: {name: string}[]
}

export class Book implements BookInterface {

  constructor(
    public id: number,
    public isbn: string,
    public title?: string,
    public author?: string, // @future make this an Author ID with new Author model, then hydrate downstream
    public genre?: string, // @future make this a Genre ID with new Genre model, allows easier filtering, etc
    public summary?: string,
    public description?: string,
    public released?: Date,
    public cover?: {small: string, medium: string, large: string},
    public authors?: {name: string}[]
  ) {}
  
  static fromJson(json: Partial<Book>): Book {
    return new Book(
      json.id,
      json.isbn,
      json.title,
      json.author,
      json.genre,
      json.summary,
      json.description,
      json.released,
      json.cover
    )
  }
}

result-matching ""

    No results matching ""