feat(persistance) : add DAO
This commit is contained in:
21
src/app/dao/ProductDAO.ts
Normal file
21
src/app/dao/ProductDAO.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Product } from '../models/Product';
|
||||
import { BaseDAO } from './BaseDAO';
|
||||
import { DBProduct } from '../models/db/DBProduct';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class ProductDAO extends BaseDAO<Product, DBProduct, DBProduct> {
|
||||
constructor() {
|
||||
super(Product.name);
|
||||
}
|
||||
|
||||
protected override toDB(model: Product): DBProduct {
|
||||
return new Product(model.barcode, model.name, model.image, model.id);
|
||||
}
|
||||
|
||||
protected override fromDB(qR: DBProduct): Product {
|
||||
return new DBProduct(qR.barcode, qR.name, qR.image, qR.id);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user