feat(persistance) : add DAO

This commit is contained in:
2026-01-17 15:01:16 -03:00
parent 8b462f98f6
commit fd763cc162
7 changed files with 310 additions and 0 deletions

21
src/app/dao/ProductDAO.ts Normal file
View 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);
}
}