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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c)
3
+ Copyright (c) 2025 Lasse Vestergaard
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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, where?: Partial<DT[K]>): Promise<DT[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, where?: Partial<DT[K]>): Promise<DT[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, where) {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "driftsql",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "author": "lasse vestergaard",
5
5
  "description": "A lightweight SQL client for TypeScript, supporting multiple databases like PostgreSQL, MySQL, and LibSQL.",
6
6
  "repository": "lassejlv/driftsql",