@spfn/core 0.1.0-alpha.49 → 0.1.0-alpha.50
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/db/index.d.ts +7 -7
- package/dist/db/index.js +7 -7
- package/dist/db/index.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/server/index.js +7 -7
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/db/index.d.ts
CHANGED
|
@@ -324,7 +324,7 @@ type WhereObject<T> = {
|
|
|
324
324
|
* ```
|
|
325
325
|
*/
|
|
326
326
|
declare function findOne<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>>): Promise<InferSelectModel<T> | null>;
|
|
327
|
-
declare function findOne<T extends PgTable>(table: T, where: SQL): Promise<InferSelectModel<T> | null>;
|
|
327
|
+
declare function findOne<T extends PgTable>(table: T, where: SQL | undefined): Promise<InferSelectModel<T> | null>;
|
|
328
328
|
/**
|
|
329
329
|
* Find multiple records
|
|
330
330
|
*
|
|
@@ -356,7 +356,7 @@ declare function findOne<T extends PgTable>(table: T, where: SQL): Promise<Infer
|
|
|
356
356
|
* ```
|
|
357
357
|
*/
|
|
358
358
|
declare function findMany<T extends PgTable>(table: T, options?: {
|
|
359
|
-
where?: WhereObject<InferSelectModel<T>> | SQL;
|
|
359
|
+
where?: WhereObject<InferSelectModel<T>> | SQL | undefined;
|
|
360
360
|
orderBy?: SQL | SQL[];
|
|
361
361
|
limit?: number;
|
|
362
362
|
offset?: number;
|
|
@@ -410,7 +410,7 @@ declare function createMany<T extends PgTable>(table: T, data: InferInsertModel<
|
|
|
410
410
|
* const user = await updateOne(users, eq(users.id, 1), { name: 'Updated Name' });
|
|
411
411
|
* ```
|
|
412
412
|
*/
|
|
413
|
-
declare function updateOne<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL, data: Partial<InferInsertModel<T>>): Promise<InferSelectModel<T> | null>;
|
|
413
|
+
declare function updateOne<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL | undefined, data: Partial<InferInsertModel<T>>): Promise<InferSelectModel<T> | null>;
|
|
414
414
|
/**
|
|
415
415
|
* Update multiple records
|
|
416
416
|
*
|
|
@@ -427,7 +427,7 @@ declare function updateOne<T extends PgTable>(table: T, where: WhereObject<Infer
|
|
|
427
427
|
* );
|
|
428
428
|
* ```
|
|
429
429
|
*/
|
|
430
|
-
declare function updateMany<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL, data: Partial<InferInsertModel<T>>): Promise<InferSelectModel<T>[]>;
|
|
430
|
+
declare function updateMany<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL | undefined, data: Partial<InferInsertModel<T>>): Promise<InferSelectModel<T>[]>;
|
|
431
431
|
/**
|
|
432
432
|
* Delete a single record
|
|
433
433
|
*
|
|
@@ -444,7 +444,7 @@ declare function updateMany<T extends PgTable>(table: T, where: WhereObject<Infe
|
|
|
444
444
|
* const user = await deleteOne(users, eq(users.id, 1));
|
|
445
445
|
* ```
|
|
446
446
|
*/
|
|
447
|
-
declare function deleteOne<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL): Promise<InferSelectModel<T> | null>;
|
|
447
|
+
declare function deleteOne<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL | undefined): Promise<InferSelectModel<T> | null>;
|
|
448
448
|
/**
|
|
449
449
|
* Delete multiple records
|
|
450
450
|
*
|
|
@@ -457,7 +457,7 @@ declare function deleteOne<T extends PgTable>(table: T, where: WhereObject<Infer
|
|
|
457
457
|
* const users = await deleteMany(users, { verified: false });
|
|
458
458
|
* ```
|
|
459
459
|
*/
|
|
460
|
-
declare function deleteMany<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL): Promise<InferSelectModel<T>[]>;
|
|
460
|
+
declare function deleteMany<T extends PgTable>(table: T, where: WhereObject<InferSelectModel<T>> | SQL | undefined): Promise<InferSelectModel<T>[]>;
|
|
461
461
|
/**
|
|
462
462
|
* Count records
|
|
463
463
|
*
|
|
@@ -472,6 +472,6 @@ declare function deleteMany<T extends PgTable>(table: T, where: WhereObject<Infe
|
|
|
472
472
|
* const adults = await count(users, gt(users.age, 18));
|
|
473
473
|
* ```
|
|
474
474
|
*/
|
|
475
|
-
declare function count<T extends PgTable>(table: T, where?: WhereObject<InferSelectModel<T>> | SQL): Promise<number>;
|
|
475
|
+
declare function count<T extends PgTable>(table: T, where?: WhereObject<InferSelectModel<T>> | SQL | undefined): Promise<number>;
|
|
476
476
|
|
|
477
477
|
export { type DatabaseClients, type PoolConfig, type RetryConfig, checkConnection, closeDatabase, count, create, createDatabaseConnection, createDatabaseFromEnv, createMany, deleteMany, deleteOne, findMany, findOne, getDatabase, getDatabaseInfo, initDatabase, setDatabase, updateMany, updateOne };
|
package/dist/db/index.js
CHANGED
|
@@ -1779,7 +1779,7 @@ async function findOne(table, where) {
|
|
|
1779
1779
|
if (!db) {
|
|
1780
1780
|
throw new Error("Database not initialized. Call initDatabase() first.");
|
|
1781
1781
|
}
|
|
1782
|
-
const whereClause = isSQLWrapper(where) ? where : buildWhereFromObject(table, where);
|
|
1782
|
+
const whereClause = isSQLWrapper(where) ? where : where ? buildWhereFromObject(table, where) : void 0;
|
|
1783
1783
|
if (!whereClause) {
|
|
1784
1784
|
throw new Error("findOne requires at least one where condition");
|
|
1785
1785
|
}
|
|
@@ -1793,7 +1793,7 @@ async function findMany(table, options) {
|
|
|
1793
1793
|
}
|
|
1794
1794
|
let query = db.select().from(table);
|
|
1795
1795
|
if (options?.where) {
|
|
1796
|
-
const whereClause = isSQLWrapper(options.where) ? options.where : buildWhereFromObject(table, options.where);
|
|
1796
|
+
const whereClause = isSQLWrapper(options.where) ? options.where : options.where ? buildWhereFromObject(table, options.where) : void 0;
|
|
1797
1797
|
if (whereClause) {
|
|
1798
1798
|
query = query.where(whereClause);
|
|
1799
1799
|
}
|
|
@@ -1831,7 +1831,7 @@ async function updateOne(table, where, data) {
|
|
|
1831
1831
|
if (!db) {
|
|
1832
1832
|
throw new Error("Database not initialized. Call initDatabase() first.");
|
|
1833
1833
|
}
|
|
1834
|
-
const whereClause = isSQLWrapper(where) ? where : buildWhereFromObject(table, where);
|
|
1834
|
+
const whereClause = isSQLWrapper(where) ? where : where ? buildWhereFromObject(table, where) : void 0;
|
|
1835
1835
|
if (!whereClause) {
|
|
1836
1836
|
throw new Error("updateOne requires at least one where condition");
|
|
1837
1837
|
}
|
|
@@ -1843,7 +1843,7 @@ async function updateMany(table, where, data) {
|
|
|
1843
1843
|
if (!db) {
|
|
1844
1844
|
throw new Error("Database not initialized. Call initDatabase() first.");
|
|
1845
1845
|
}
|
|
1846
|
-
const whereClause = isSQLWrapper(where) ? where : buildWhereFromObject(table, where);
|
|
1846
|
+
const whereClause = isSQLWrapper(where) ? where : where ? buildWhereFromObject(table, where) : void 0;
|
|
1847
1847
|
if (!whereClause) {
|
|
1848
1848
|
throw new Error("updateMany requires at least one where condition");
|
|
1849
1849
|
}
|
|
@@ -1855,7 +1855,7 @@ async function deleteOne(table, where) {
|
|
|
1855
1855
|
if (!db) {
|
|
1856
1856
|
throw new Error("Database not initialized. Call initDatabase() first.");
|
|
1857
1857
|
}
|
|
1858
|
-
const whereClause = isSQLWrapper(where) ? where : buildWhereFromObject(table, where);
|
|
1858
|
+
const whereClause = isSQLWrapper(where) ? where : where ? buildWhereFromObject(table, where) : void 0;
|
|
1859
1859
|
if (!whereClause) {
|
|
1860
1860
|
throw new Error("deleteOne requires at least one where condition");
|
|
1861
1861
|
}
|
|
@@ -1867,7 +1867,7 @@ async function deleteMany(table, where) {
|
|
|
1867
1867
|
if (!db) {
|
|
1868
1868
|
throw new Error("Database not initialized. Call initDatabase() first.");
|
|
1869
1869
|
}
|
|
1870
|
-
const whereClause = isSQLWrapper(where) ? where : buildWhereFromObject(table, where);
|
|
1870
|
+
const whereClause = isSQLWrapper(where) ? where : where ? buildWhereFromObject(table, where) : void 0;
|
|
1871
1871
|
if (!whereClause) {
|
|
1872
1872
|
throw new Error("deleteMany requires at least one where condition");
|
|
1873
1873
|
}
|
|
@@ -1881,7 +1881,7 @@ async function count(table, where) {
|
|
|
1881
1881
|
}
|
|
1882
1882
|
let query = db.select().from(table);
|
|
1883
1883
|
if (where) {
|
|
1884
|
-
const whereClause = isSQLWrapper(where) ? where : buildWhereFromObject(table, where);
|
|
1884
|
+
const whereClause = isSQLWrapper(where) ? where : where ? buildWhereFromObject(table, where) : void 0;
|
|
1885
1885
|
if (whereClause) {
|
|
1886
1886
|
query = query.where(whereClause);
|
|
1887
1887
|
}
|