refactor(ocr): update timestamp handling to use milliseconds

Use dayjs().valueOf() instead of dayjs().unix() to get timestamps in milliseconds for consistency with the updated schema comment
This commit is contained in:
icarus 2025-10-20 08:21:18 +08:00
parent 6f635472f3
commit e4b5e70c34
2 changed files with 4 additions and 4 deletions

View File

@ -39,7 +39,7 @@ export const ocrProviderTable = sqliteTable(
*/
config: text('config', { mode: 'json' }).$type<OcrProviderConfig>().notNull(),
/** Timestamps. May not useful. */
/** Unix timestamp (milliseconds since epoch) for creation and last update. */
...createUpdateTimestamps
},
(t) => [index('name').on(t.name)]

View File

@ -92,7 +92,7 @@ export class OcrService {
throw new Error(`OCR provider ${update.id} not found`)
}
const found = providers[0]
const newProvider = { ...merge({}, found, update), updatedAt: dayjs().unix() } satisfies DbOcrProvider
const newProvider = { ...merge({}, found, update), updatedAt: dayjs().valueOf() } satisfies DbOcrProvider
const [updated] = await dbService
.getDb()
.update(ocrProviderTable)
@ -114,7 +114,7 @@ export class OcrService {
throw new Error(`OCR provider ${create.id} already exists`)
}
const timestamp = dayjs().unix()
const timestamp = dayjs().valueOf()
const newProvider = {
...create,
createdAt: timestamp,
@ -137,7 +137,7 @@ export class OcrService {
.where(eq(ocrProviderTable.id, provider.id))
.limit(1)
const timestamp = dayjs().unix()
const timestamp = dayjs().valueOf()
if (providers.length === 0) {
const newProvider = {
...provider,