@dascompany/product 4.0.10 → 4.0.11

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/SQL.json CHANGED
@@ -19,8 +19,9 @@
19
19
  },
20
20
  "accountCart": {
21
21
  "select": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT",
22
- "insert": "INSERT INTO clients.account_cart(account_id, product_id) VALUES ($account_id::BIGINT, $product_id::BIGINT)",
23
- "delete": "DELETE FROM clients.account_cart WHERE product_id = $product_id::BIGINT AND account_id = $account_id::BIGINT"
22
+ "insert": "INSERT INTO clients.account_cart(account_id, product_id, installation) VALUES ($account_id::BIGINT, $product_id::BIGINT, installation::BOOL)",
23
+ "update": "UPDATE clients.account_cart SET installation = $installation WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT AND installation = $installation::Bool",
24
+ "delete": "DELETE FROM clients.account_cart WHERE product_id = $product_id::BIGINT AND account_id = $account_id::BIGINT AND installation = $installation::BOOL"
24
25
  },
25
26
  "accountDeliveryDetails": {
26
27
  "select": "SELECT * FROM clients.account_delivery_details WHERE account_id = $account_id::BIGINT",
@@ -2,7 +2,8 @@ import { Table } from '@dascompany/database';
2
2
  import AccountCartRow from '../../types/rows/AccountCartRow';
3
3
  export default class AccountCartTable extends Table {
4
4
  selectAll(accountId: string): Promise<AccountCartRow[]>;
5
- delete(accountId: string, productId: string): Promise<void>;
6
- insert(accountId: string, productId: string): Promise<void>;
5
+ delete(accountId: string, productId: string, installation: boolean): Promise<void>;
6
+ insert(accountId: string, productId: string, installation: boolean): Promise<void>;
7
+ update(accountId: string, productId: string, oldInstallation: boolean, newInstallation: boolean): Promise<void>;
7
8
  private bindParams;
8
9
  }
@@ -7,18 +7,24 @@ export default class AccountCartTable extends Table {
7
7
  const result = await query.execute();
8
8
  return result.getRows();
9
9
  }
10
- async delete(accountId, productId) {
10
+ async delete(accountId, productId, installation) {
11
11
  const query = this.createQuery(SQL.accountCart.delete);
12
- this.bindParams(query, accountId, productId);
12
+ this.bindParams(query, accountId, productId, installation);
13
13
  await query.execute();
14
14
  }
15
- async insert(accountId, productId) {
15
+ async insert(accountId, productId, installation) {
16
16
  const query = this.createQuery(SQL.accountCart.insert);
17
- this.bindParams(query, accountId, productId);
17
+ this.bindParams(query, accountId, productId, installation);
18
18
  await query.execute();
19
19
  }
20
- bindParams(query, accountId, productId) {
20
+ async update(accountId, productId, oldInstallation, newInstallation) {
21
+ const query = this.createQuery(SQL.accountCart.update);
22
+ this.bindParams(query, accountId, productId, newInstallation);
23
+ await query.execute();
24
+ }
25
+ bindParams(query, accountId, productId, installation) {
21
26
  query.bindParameter('account_id', accountId);
22
27
  query.bindParameter('product_id', productId);
28
+ query.bindParameter('installation', installation);
23
29
  }
24
30
  }
@@ -1,4 +1,5 @@
1
1
  export default class AccountCart {
2
- static delete(accountId: string, productId: string): Promise<boolean>;
3
- static insert(accountId: string, productId: string): Promise<boolean>;
2
+ static delete(accountId: string, productId: string, installation: boolean): Promise<boolean>;
3
+ static insert(accountId: string, productId: string, installation: boolean): Promise<boolean>;
4
+ static update(accountId: string, productId: string, oldInstallation: boolean, installation: boolean): Promise<boolean>;
4
5
  }
@@ -1,11 +1,15 @@
1
1
  import DatabaseConnection from "../DatabaseConnection";
2
2
  export default class AccountCart {
3
- static async delete(accountId, productId) {
4
- await DatabaseConnection.getInstance().accountCart.delete(accountId, productId);
3
+ static async delete(accountId, productId, installation) {
4
+ await DatabaseConnection.getInstance().accountCart.delete(accountId, productId, installation);
5
5
  return true;
6
6
  }
7
- static async insert(accountId, productId) {
8
- await DatabaseConnection.getInstance().accountCart.insert(accountId, productId);
7
+ static async insert(accountId, productId, installation) {
8
+ await DatabaseConnection.getInstance().accountCart.insert(accountId, productId, installation);
9
+ return true;
10
+ }
11
+ static async update(accountId, productId, oldInstallation, installation) {
12
+ await DatabaseConnection.getInstance().accountCart.update(accountId, productId, oldInstallation, installation);
9
13
  return true;
10
14
  }
11
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dascompany/product",
3
- "version": "4.0.10",
3
+ "version": "4.0.11",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "test": "vitest",