@inflector/optima-pg 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -357,6 +357,8 @@ declare class Table<T extends Record<string, AnyColumn>> {
|
|
|
357
357
|
private serializeDates;
|
|
358
358
|
private getVectorCols;
|
|
359
359
|
private deserializeRow;
|
|
360
|
+
private isPostgresTimestamp;
|
|
361
|
+
private isISOTimestamp;
|
|
360
362
|
Get<TCols extends keyof InferSchema<T> = keyof InferSchema<T>>(cols?: TCols[]): {
|
|
361
363
|
limit: (arg: number) => {
|
|
362
364
|
offset: (arg: number) => {
|
package/dist/index.js
CHANGED
|
@@ -428,7 +428,15 @@ var Table = class {
|
|
|
428
428
|
serializeDates(row) {
|
|
429
429
|
return Object.fromEntries(
|
|
430
430
|
Object.entries(row).map(([k, v]) => {
|
|
431
|
-
if (v instanceof Date)
|
|
431
|
+
if (v instanceof Date) {
|
|
432
|
+
return [k, v.toISOString().replace("T", " ").replace("Z", "+00")];
|
|
433
|
+
}
|
|
434
|
+
if (typeof v === "string" && this.isPostgresTimestamp(v)) {
|
|
435
|
+
return [k, v];
|
|
436
|
+
}
|
|
437
|
+
if (typeof v === "string" && this.isISOTimestamp(v)) {
|
|
438
|
+
return [k, v.replace("T", " ").replace("Z", "+00")];
|
|
439
|
+
}
|
|
432
440
|
if (Array.isArray(v) && v.every((i) => typeof i === "number")) {
|
|
433
441
|
return [k, `[${v.join(",")}]`];
|
|
434
442
|
}
|
|
@@ -455,6 +463,14 @@ var Table = class {
|
|
|
455
463
|
})
|
|
456
464
|
);
|
|
457
465
|
}
|
|
466
|
+
// 2026-02-18 23:09:43.766654+00
|
|
467
|
+
isPostgresTimestamp(v) {
|
|
468
|
+
return /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(v);
|
|
469
|
+
}
|
|
470
|
+
// 2026-02-18T23:09:43.766Z
|
|
471
|
+
isISOTimestamp(v) {
|
|
472
|
+
return /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(v);
|
|
473
|
+
}
|
|
458
474
|
// ── CRUD ────────────────────────────────────────────────────────────────────
|
|
459
475
|
Get(cols) {
|
|
460
476
|
return createFluentBuilder2(async (data) => {
|
|
@@ -602,10 +618,8 @@ var init = async (db, client, tables, isPGlite) => {
|
|
|
602
618
|
FOR EACH ROW EXECUTE FUNCTION notify_table_change();
|
|
603
619
|
`;
|
|
604
620
|
if (isPGlite) {
|
|
605
|
-
await client.query(tableSQL);
|
|
606
621
|
await client.query(triggerSQL);
|
|
607
622
|
} else {
|
|
608
|
-
await sql2.raw(tableSQL).execute(db);
|
|
609
623
|
await sql2.raw(triggerSQL).execute(db);
|
|
610
624
|
}
|
|
611
625
|
}
|