@onebun/drizzle 0.1.7 → 0.1.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onebun/drizzle",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Drizzle ORM module for OneBun framework - SQLite and PostgreSQL support",
5
5
  "license": "LGPL-3.0",
6
6
  "author": "RemRyahirev",
@@ -47,7 +47,7 @@
47
47
  "dev": "bun run --watch src/index.ts"
48
48
  },
49
49
  "dependencies": {
50
- "@onebun/core": "^0.1.11",
50
+ "@onebun/core": "^0.1.13",
51
51
  "@onebun/envs": "^0.1.4",
52
52
  "@onebun/logger": "^0.1.5",
53
53
  "drizzle-orm": "^0.44.7",
@@ -525,4 +525,135 @@ export class DrizzleService<TDbType extends DatabaseTypeLiteral = DatabaseTypeLi
525
525
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
526
526
  return await (this.db as any).transaction(callback);
527
527
  }
528
+
529
+ // ============================================
530
+ // Direct database operation methods (proxies)
531
+ // ============================================
532
+
533
+ /**
534
+ * Create a SELECT query
535
+ *
536
+ * @example
537
+ * ```typescript
538
+ * // Select all columns
539
+ * const users = await this.db.select().from(usersTable);
540
+ *
541
+ * // Select specific columns
542
+ * const names = await this.db.select({ name: usersTable.name }).from(usersTable);
543
+ * ```
544
+ */
545
+ select(): ReturnType<DatabaseInstanceForType<TDbType>['select']>;
546
+ select<TSelection extends Record<string, unknown>>(
547
+ fields: TSelection,
548
+ ): ReturnType<DatabaseInstanceForType<TDbType>['select']>;
549
+ select<TSelection extends Record<string, unknown>>(
550
+ fields?: TSelection,
551
+ ): ReturnType<DatabaseInstanceForType<TDbType>['select']> {
552
+ const db = this.getDatabase();
553
+ if (fields) {
554
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
555
+ return (db as any).select(fields);
556
+ }
557
+
558
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
559
+ return (db as any).select();
560
+ }
561
+
562
+ /**
563
+ * Create a SELECT DISTINCT query
564
+ *
565
+ * @example
566
+ * ```typescript
567
+ * // Select distinct values
568
+ * const uniqueNames = await this.db.selectDistinct({ name: usersTable.name }).from(usersTable);
569
+ * ```
570
+ */
571
+ selectDistinct(): ReturnType<DatabaseInstanceForType<TDbType>['selectDistinct']>;
572
+ selectDistinct<TSelection extends Record<string, unknown>>(
573
+ fields: TSelection,
574
+ ): ReturnType<DatabaseInstanceForType<TDbType>['selectDistinct']>;
575
+ selectDistinct<TSelection extends Record<string, unknown>>(
576
+ fields?: TSelection,
577
+ ): ReturnType<DatabaseInstanceForType<TDbType>['selectDistinct']> {
578
+ const db = this.getDatabase();
579
+ if (fields) {
580
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
581
+ return (db as any).selectDistinct(fields);
582
+ }
583
+
584
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
585
+ return (db as any).selectDistinct();
586
+ }
587
+
588
+ /**
589
+ * Create an INSERT query
590
+ *
591
+ * @example
592
+ * ```typescript
593
+ * // Insert a single row
594
+ * await this.db.insert(usersTable).values({ name: 'John', email: 'john@example.com' });
595
+ *
596
+ * // Insert with returning
597
+ * const [newUser] = await this.db.insert(usersTable)
598
+ * .values({ name: 'John', email: 'john@example.com' })
599
+ * .returning();
600
+ * ```
601
+ */
602
+ insert<TTable extends Parameters<DatabaseInstanceForType<TDbType>['insert']>[0]>(
603
+ table: TTable,
604
+ ): ReturnType<DatabaseInstanceForType<TDbType>['insert']> {
605
+ const db = this.getDatabase();
606
+
607
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
608
+ return (db as any).insert(table);
609
+ }
610
+
611
+ /**
612
+ * Create an UPDATE query
613
+ *
614
+ * @example
615
+ * ```typescript
616
+ * // Update rows
617
+ * await this.db.update(usersTable)
618
+ * .set({ name: 'Jane' })
619
+ * .where(eq(usersTable.id, 1));
620
+ *
621
+ * // Update with returning
622
+ * const [updated] = await this.db.update(usersTable)
623
+ * .set({ name: 'Jane' })
624
+ * .where(eq(usersTable.id, 1))
625
+ * .returning();
626
+ * ```
627
+ */
628
+ update<TTable extends Parameters<DatabaseInstanceForType<TDbType>['update']>[0]>(
629
+ table: TTable,
630
+ ): ReturnType<DatabaseInstanceForType<TDbType>['update']> {
631
+ const db = this.getDatabase();
632
+
633
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
634
+ return (db as any).update(table);
635
+ }
636
+
637
+ /**
638
+ * Create a DELETE query
639
+ *
640
+ * @example
641
+ * ```typescript
642
+ * // Delete rows
643
+ * await this.db.delete(usersTable).where(eq(usersTable.id, 1));
644
+ *
645
+ * // Delete with returning
646
+ * const [deleted] = await this.db.delete(usersTable)
647
+ * .where(eq(usersTable.id, 1))
648
+ * .returning();
649
+ * ```
650
+ */
651
+ delete<TTable extends Parameters<DatabaseInstanceForType<TDbType>['delete']>[0]>(
652
+ table: TTable,
653
+ ): ReturnType<DatabaseInstanceForType<TDbType>['delete']> {
654
+ const db = this.getDatabase();
655
+
656
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
657
+ return (db as any).delete(table);
658
+ }
528
659
  }