mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 11:20:07 +08:00
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:
parent
6f635472f3
commit
e4b5e70c34
@ -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)]
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user