@dascompany/product 4.2.2 → 4.2.3
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 +2 -3
- package/dist/reader/AccountCartReader.d.ts +2 -0
- package/dist/reader/AccountCartReader.js +8 -1
- package/dist/tables/clients/AccountCartTable.d.ts +3 -4
- package/dist/tables/clients/AccountCartTable.js +4 -13
- package/dist/utils/AccountCart.d.ts +2 -1
- package/dist/utils/AccountCart.js +4 -2
- package/package.json +1 -1
package/dist/SQL.json
CHANGED
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
"selectNextId": "SELECT nextval('clients.accounts_id'::regclass)"
|
|
19
19
|
},
|
|
20
20
|
"accountCart": {
|
|
21
|
-
"
|
|
22
|
-
"select": "SELECT * FROM clients.account_cart WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT",
|
|
21
|
+
"select": "SELECT * FROM clients.account_cart ",
|
|
23
22
|
"insert": "INSERT INTO clients.account_cart(account_id, product_id, installation, quantity) VALUES ($account_id::BIGINT, $product_id::BIGINT, $installation::BOOL, $quantity::INT)",
|
|
24
23
|
"update": "UPDATE clients.account_cart SET installation = $installation::BOOL, quantity = $quantity::INT WHERE account_id = $account_id::BIGINT AND product_id = $product_id::BIGINT AND (installation != $installation::BOOL OR quantity != $quantity::INT)",
|
|
25
|
-
"delete": "DELETE FROM clients.account_cart
|
|
24
|
+
"delete": "DELETE FROM clients.account_cart "
|
|
26
25
|
},
|
|
27
26
|
"accountDeliveryDetails": {
|
|
28
27
|
"select": "SELECT * FROM clients.account_delivery_details WHERE account_id = $account_id::BIGINT",
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { ParameterType, QueryOptions } from "@dascompany/database";
|
|
1
2
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
3
|
export default class AccountCartReader {
|
|
3
4
|
static async getAll(accountId) {
|
|
4
|
-
const
|
|
5
|
+
const queryOptions = new QueryOptions();
|
|
6
|
+
queryOptions.setWhere([{ name: 'account_id', type: ParameterType.bigint, value: accountId }]);
|
|
7
|
+
const accountCart = await DatabaseConnection.getInstance().accountCart.select(queryOptions);
|
|
8
|
+
return this.correctAccountCart(accountCart);
|
|
9
|
+
}
|
|
10
|
+
static async get(queryOptions) {
|
|
11
|
+
const accountCart = await DatabaseConnection.getInstance().accountCart.select(queryOptions);
|
|
5
12
|
return this.correctAccountCart(accountCart);
|
|
6
13
|
}
|
|
7
14
|
static async correctAccountCart(accountCart) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Table } from '@dascompany/database';
|
|
1
|
+
import { QueryOptions, Table } from '@dascompany/database';
|
|
2
2
|
import AccountCartRow from '../../types/rows/AccountCartRow';
|
|
3
3
|
import AccountCartItem from '../../stockObjects/AccountCartItem.ts';
|
|
4
4
|
export default class AccountCartTable extends Table {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
delete(accountId: string, productId: string): Promise<void>;
|
|
5
|
+
select(queryOptions: QueryOptions): Promise<AccountCartRow[]>;
|
|
6
|
+
delete(queryOptions: QueryOptions): Promise<void>;
|
|
8
7
|
insert(accountCartItem: AccountCartItem): Promise<void>;
|
|
9
8
|
update(accountCartItem: AccountCartItem): Promise<void>;
|
|
10
9
|
private bindParams;
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { Table } from '@dascompany/database';
|
|
2
2
|
import * as SQL from '../../SQL.json';
|
|
3
3
|
export default class AccountCartTable extends Table {
|
|
4
|
-
async
|
|
5
|
-
const query = this.createQuery(SQL.accountCart.
|
|
6
|
-
query.bindParameter('account_id', accountId);
|
|
4
|
+
async select(queryOptions) {
|
|
5
|
+
const query = this.createQuery(SQL.accountCart.select, queryOptions);
|
|
7
6
|
const result = await query.execute();
|
|
8
7
|
return result.getRows();
|
|
9
8
|
}
|
|
10
|
-
async
|
|
11
|
-
const query = this.createQuery(SQL.accountCart.
|
|
12
|
-
query.bindParameter('account_id', accountId);
|
|
13
|
-
query.bindParameter('product_id', productId);
|
|
14
|
-
const result = await query.execute();
|
|
15
|
-
return result.getRow();
|
|
16
|
-
}
|
|
17
|
-
async delete(accountId, productId) {
|
|
18
|
-
const query = this.createQuery(SQL.accountCart.delete);
|
|
19
|
-
this.bindParams(query, accountId, productId);
|
|
9
|
+
async delete(queryOptions) {
|
|
10
|
+
const query = this.createQuery(SQL.accountCart.delete, queryOptions);
|
|
20
11
|
await query.execute();
|
|
21
12
|
}
|
|
22
13
|
async insert(accountCartItem) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { QueryOptions } from "@dascompany/database";
|
|
1
2
|
export default class AccountCart {
|
|
2
|
-
static delete(
|
|
3
|
+
static delete(queryOptions: QueryOptions): Promise<boolean>;
|
|
3
4
|
static insert(accountId: string, productId: string, installation: boolean, quantity: number): Promise<boolean>;
|
|
4
5
|
static update(accountId: string, productId: string, installation: boolean, quantity: number): Promise<boolean>;
|
|
5
6
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import DatabaseConnection from "../DatabaseConnection";
|
|
2
2
|
import AccountCartItem from "../stockObjects/AccountCartItem.ts";
|
|
3
3
|
export default class AccountCart {
|
|
4
|
-
static async delete(
|
|
5
|
-
|
|
4
|
+
static async delete(queryOptions) {
|
|
5
|
+
if (!queryOptions.getWhere()?.parameters.length)
|
|
6
|
+
throw new Error("you can't delete table elements without query options where");
|
|
7
|
+
await DatabaseConnection.getInstance().accountCart.delete(queryOptions);
|
|
6
8
|
return true;
|
|
7
9
|
}
|
|
8
10
|
static async insert(accountId, productId, installation, quantity) {
|