mirror of
https://github.com/morten-olsen/reservoir.git
synced 2026-02-08 01:46:24 +01:00
fix: postgres object compat
This commit is contained in:
@@ -27,10 +27,10 @@ type DocumentRow = {
|
||||
id: string;
|
||||
type: string;
|
||||
source: string | null;
|
||||
data: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
data: string | unknown;
|
||||
createdAt: string | Date;
|
||||
updatedAt: string | Date;
|
||||
deletedAt: string | Date | null;
|
||||
};
|
||||
|
||||
type Tables = {
|
||||
|
||||
@@ -49,15 +49,15 @@ class DocumentsService {
|
||||
action: 'inserted',
|
||||
};
|
||||
}
|
||||
const currentData = JSON.parse(current.data);
|
||||
const currentData = typeof current.data === 'string' ? JSON.parse(current.data) : current.data;
|
||||
if (equal(currentData, document.data)) {
|
||||
return {
|
||||
...current,
|
||||
data: currentData,
|
||||
id,
|
||||
createdAt: current.createdAt,
|
||||
updatedAt: current.updatedAt,
|
||||
deletedAt: current.deletedAt || null,
|
||||
createdAt: new Date(current.createdAt).toISOString(),
|
||||
updatedAt: new Date(current.updatedAt).toISOString(),
|
||||
deletedAt: current.deletedAt ? new Date(current.deletedAt).toISOString() : null,
|
||||
action: 'skipped',
|
||||
};
|
||||
}
|
||||
@@ -72,9 +72,9 @@ class DocumentsService {
|
||||
...current,
|
||||
id,
|
||||
data: document.data,
|
||||
createdAt: current.createdAt,
|
||||
createdAt: new Date(current.createdAt).toISOString(),
|
||||
updatedAt: now.toISOString(),
|
||||
deletedAt: current.deletedAt || null,
|
||||
deletedAt: current.deletedAt ? new Date(current.deletedAt).toISOString() : null,
|
||||
action: 'updated',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -3,3 +3,4 @@ packages:
|
||||
- ./apps/*
|
||||
onlyBuiltDependencies:
|
||||
- better-sqlite3
|
||||
- esbuild
|
||||
|
||||
Reference in New Issue
Block a user