driftsql 1.0.3 → 1.0.4
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/LICENSE +1 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +6 -15
- package/package.json +1 -1
package/LICENSE
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -43,7 +43,10 @@ declare class DriftSQLClient<DT> {
|
|
|
43
43
|
ping: number;
|
|
44
44
|
}>;
|
|
45
45
|
findFirst<K extends keyof DT>(table: K, where?: Partial<DT[K]>): Promise<DT[K] | null>;
|
|
46
|
-
findMany<K extends keyof DT>(table: K,
|
|
46
|
+
findMany<K extends keyof DT>(table: K, options?: {
|
|
47
|
+
where?: Partial<DT[K]>;
|
|
48
|
+
limit?: number;
|
|
49
|
+
}): Promise<DT[K][]>;
|
|
47
50
|
insert<K extends keyof DT>(table: K, data: Partial<DT[K]>): Promise<DT[K]>;
|
|
48
51
|
update<K extends keyof DT>(table: K, data: Partial<DT[K]>, where: Partial<DT[K]>): Promise<DT[K] | null>;
|
|
49
52
|
delete<K extends keyof DT>(table: K, where: Partial<DT[K]>): Promise<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,10 @@ declare class DriftSQLClient<DT> {
|
|
|
43
43
|
ping: number;
|
|
44
44
|
}>;
|
|
45
45
|
findFirst<K extends keyof DT>(table: K, where?: Partial<DT[K]>): Promise<DT[K] | null>;
|
|
46
|
-
findMany<K extends keyof DT>(table: K,
|
|
46
|
+
findMany<K extends keyof DT>(table: K, options?: {
|
|
47
|
+
where?: Partial<DT[K]>;
|
|
48
|
+
limit?: number;
|
|
49
|
+
}): Promise<DT[K][]>;
|
|
47
50
|
insert<K extends keyof DT>(table: K, data: Partial<DT[K]>): Promise<DT[K]>;
|
|
48
51
|
update<K extends keyof DT>(table: K, data: Partial<DT[K]>, where: Partial<DT[K]>): Promise<DT[K] | null>;
|
|
49
52
|
delete<K extends keyof DT>(table: K, where: Partial<DT[K]>): Promise<boolean>;
|
package/dist/index.mjs
CHANGED
|
@@ -247,20 +247,6 @@ class DriftSQLClient {
|
|
|
247
247
|
throw error;
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
|
-
if (this.neonClient) {
|
|
251
|
-
try {
|
|
252
|
-
const sql = this.neonClient;
|
|
253
|
-
console.log(sql);
|
|
254
|
-
throw new Error("Neon client is not implemented yet");
|
|
255
|
-
return {
|
|
256
|
-
rows: [],
|
|
257
|
-
rowCount: 0
|
|
258
|
-
};
|
|
259
|
-
} catch (error) {
|
|
260
|
-
consola.error("Failed to execute query with Neon:", error);
|
|
261
|
-
throw error;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
250
|
try {
|
|
265
251
|
const response = await this.client.post("query", {
|
|
266
252
|
json: { query, args: args || [] }
|
|
@@ -294,8 +280,9 @@ class DriftSQLClient {
|
|
|
294
280
|
const result = await this.query(query, args);
|
|
295
281
|
return result.rows[0] || null;
|
|
296
282
|
}
|
|
297
|
-
async findMany(table,
|
|
283
|
+
async findMany(table, options) {
|
|
298
284
|
const tableName = String(table);
|
|
285
|
+
const { where, limit } = options || {};
|
|
299
286
|
const whereEntries = Object.entries(where || {});
|
|
300
287
|
let query = `SELECT * FROM ${tableName}`;
|
|
301
288
|
let args = [];
|
|
@@ -304,6 +291,10 @@ class DriftSQLClient {
|
|
|
304
291
|
query += ` WHERE ${whereClause}`;
|
|
305
292
|
args = whereEntries.map(([, value]) => value);
|
|
306
293
|
}
|
|
294
|
+
if (typeof limit === "number" && limit > 0) {
|
|
295
|
+
query += ` LIMIT $${args.length + 1}`;
|
|
296
|
+
args.push(limit);
|
|
297
|
+
}
|
|
307
298
|
const result = await this.query(query, args);
|
|
308
299
|
return result.rows;
|
|
309
300
|
}
|
package/package.json
CHANGED