hono-crud 0.3.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
  %b
12
12
  %b
13
13
  %b
14
+ %b
14
15
  ## [0.1.0] - 2025-01-29
15
16
 
16
17
  ### Added
@@ -38,3 +39,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
38
39
  [0.1.4]: https://github.com/kshdotdev/hono-crud/compare/v0.1.3...v0.1.4
39
40
  [0.2.0]: https://github.com/kshdotdev/hono-crud/compare/v0.1.4...v0.2.0
40
41
  [0.3.0]: https://github.com/kshdotdev/hono-crud/compare/v0.2.0...v0.3.0
42
+ [0.3.1]: https://github.com/kshdotdev/hono-crud/compare/v0.3.0...v0.3.1
@@ -269,7 +269,7 @@ var DrizzleCreateEndpoint = class extends CreateEndpoint {
269
269
  if (!this.useTransaction) {
270
270
  return super.handle();
271
271
  }
272
- return cast(this.db).transaction(async (tx) => {
272
+ return cast(this.getDb()).transaction(async (tx) => {
273
273
  this._tx = tx;
274
274
  try {
275
275
  return await super.handle();
@@ -308,7 +308,7 @@ var DrizzleReadEndpoint = class extends ReadEndpoint {
308
308
  if (softDeleteConfig.enabled) {
309
309
  conditions.push(isNull(this.getColumn(softDeleteConfig.field)));
310
310
  }
311
- const result = await cast(this.db).select().from(table).where(and(...conditions)).limit(1);
311
+ const result = await cast(this.getDb()).select().from(table).where(and(...conditions)).limit(1);
312
312
  if (!result[0]) {
313
313
  return null;
314
314
  }
@@ -474,7 +474,7 @@ var DrizzleUpdateEndpoint = class extends UpdateEndpoint {
474
474
  if (!this.useTransaction) {
475
475
  return super.handle();
476
476
  }
477
- return cast(this.db).transaction(async (tx) => {
477
+ return cast(this.getDb()).transaction(async (tx) => {
478
478
  this._tx = tx;
479
479
  try {
480
480
  return await super.handle();
@@ -597,7 +597,7 @@ var DrizzleDeleteEndpoint = class extends DeleteEndpoint {
597
597
  if (!this.useTransaction) {
598
598
  return super.handle();
599
599
  }
600
- return cast(this.db).transaction(async (tx) => {
600
+ return cast(this.getDb()).transaction(async (tx) => {
601
601
  this._tx = tx;
602
602
  try {
603
603
  return await super.handle();
@@ -649,9 +649,10 @@ var DrizzleListEndpoint = class extends ListEndpoint {
649
649
  conditions.push(or(...searchConditions));
650
650
  }
651
651
  const whereClause = conditions.length > 0 ? and(...conditions) : void 0;
652
- const countResult = await cast(this.db).select({ count: sql`count(*)` }).from(table).where(whereClause);
652
+ const db = this.getDb();
653
+ const countResult = await cast(db).select({ count: sql`count(*)` }).from(table).where(whereClause);
653
654
  const totalCount = Number(countResult[0]?.count) || 0;
654
- let query = cast(this.db).select().from(table).where(whereClause);
655
+ let query = cast(db).select().from(table).where(whereClause);
655
656
  if (filters.options.order_by) {
656
657
  const orderColumn = this.getColumn(filters.options.order_by);
657
658
  const orderFn = filters.options.order_by_direction === "desc" ? desc : asc;
@@ -729,7 +730,7 @@ var DrizzleRestoreEndpoint = class extends RestoreEndpoint {
729
730
  if (!this.useTransaction) {
730
731
  return super.handle();
731
732
  }
732
- return cast(this.db).transaction(async (tx) => {
733
+ return cast(this.getDb()).transaction(async (tx) => {
733
734
  this._tx = tx;
734
735
  try {
735
736
  return await super.handle();
@@ -759,7 +760,7 @@ var DrizzleBatchCreateEndpoint = class extends BatchCreateEndpoint {
759
760
  ...item,
760
761
  [primaryKey]: item[primaryKey] || crypto.randomUUID()
761
762
  }));
762
- const result = await cast(this.db).insert(table).values(records).returning();
763
+ const result = await cast(this.getDb()).insert(table).values(records).returning();
763
764
  return result;
764
765
  }
765
766
  };
@@ -790,7 +791,7 @@ var DrizzleBatchUpdateEndpoint = class extends BatchUpdateEndpoint {
790
791
  if (softDeleteConfig.enabled) {
791
792
  conditions.push(isNull(this.getColumn(softDeleteConfig.field)));
792
793
  }
793
- const result = await cast(this.db).update(table).set(item.data).where(and(...conditions)).returning();
794
+ const result = await cast(this.getDb()).update(table).set(item.data).where(and(...conditions)).returning();
794
795
  if (result[0]) {
795
796
  updated.push(result[0]);
796
797
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono-crud",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "CRUD generator for Hono with Zod validation and OpenAPI generation",
5
5
  "author": "Kauan Guesser <contato@kauan.net>",
6
6
  "license": "MIT",