1 | import { bdConsulta } from "../../lib/js/bdConsulta.js" |
2 | import { exportaAHtml } from "../../lib/js/exportaAHtml.js" |
3 | import { validaPasatiempo } from "../modelo/validaPasatiempo.js" |
4 | import { ALMACEN_PASATIEMPO, Bd } from "./Bd.js" |
5 | |
6 | |
7 | |
8 | |
9 | export async function pasatiempoBusca(id) { |
10 | |
11 | return bdConsulta(Bd, [ALMACEN_PASATIEMPO], |
12 | |
13 | |
14 | |
15 | |
16 | (transaccion, resolve) => { |
17 | |
18 | |
19 | |
20 | const consulta = transaccion.objectStore(ALMACEN_PASATIEMPO).get(id) |
21 | |
22 | |
23 | consulta.onsuccess = () => { |
24 | |
25 | |
26 | |
27 | const objeto = consulta.result |
28 | if (objeto !== undefined) { |
29 | const modelo = validaPasatiempo(objeto) |
30 | if (modelo.PAS_ELIMINADO === 0) { |
31 | resolve(modelo) |
32 | return |
33 | } |
34 | } |
35 | resolve(undefined) |
36 | |
37 | } |
38 | |
39 | }) |
40 | |
41 | } |
42 | |
43 | exportaAHtml(pasatiempoBusca) |