MCPcopy Create free account
hub / github.com/pacexy/flow / constructor

Method constructor

apps/reader/src/db.ts:44–115  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

42 books!: Table<BookRecord>
43
44 constructor(name: string) {
45 super(name)
46
47 this.version(5).stores({
48 books:
49 'id, name, size, metadata, createdAt, updatedAt, cfi, percentage, definitions, annotations, configuration',
50 })
51
52 this.version(4)
53 .stores({
54 books:
55 'id, name, size, metadata, createdAt, updatedAt, cfi, percentage, definitions, annotations',
56 })
57 .upgrade(async (t) => {
58 t.table('books')
59 .toCollection()
60 .modify((r) => {
61 r.annotations = []
62 })
63 })
64
65 this.version(3)
66 .stores({
67 books:
68 'id, name, size, metadata, createdAt, updatedAt, cfi, percentage, definitions',
69 })
70 .upgrade(async (t) => {
71 const files = await t.table('files').toArray()
72
73 const metadatas = await Dexie.waitFor(
74 Promise.all(
75 files.map(async ({ file }) => {
76 const epub = await fileToEpub(file)
77 return epub.loaded.metadata
78 }),
79 ),
80 )
81
82 return t
83 .table('books')
84 .toCollection()
85 .modify(async (r) => {
86 const i = files.findIndex((f) => f.id === r.id)
87 r.metadata = metadatas[i]
88 r.size = files[i].file.size
89 })
90 .catch((e) => {
91 console.error(e)
92 throw e
93 })
94 })
95 this.version(2)
96 .stores({
97 books: 'id, name, createdAt, cfi, percentage, definitions',
98 })
99 .upgrade(async (t) => {
100 const books = await t.table('books').toArray()
101 ;['covers', 'files'].forEach((tableName) => {

Callers

nothing calls this directly

Calls 5

fileToEpubFunction · 0.90
allMethod · 0.80
mapMethod · 0.80
forEachMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected