@hedhog/pagination 0.0.16 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -4
- package/dist/databases/abstract.database.d.ts +61 -0
- package/dist/databases/abstract.database.d.ts.map +1 -0
- package/dist/databases/abstract.database.js +643 -0
- package/dist/databases/abstract.database.js.map +1 -0
- package/dist/databases/database.d.ts +5 -0
- package/dist/databases/database.d.ts.map +1 -0
- package/dist/databases/database.factory.d.ts +7 -0
- package/dist/databases/database.factory.d.ts.map +1 -0
- package/dist/databases/database.factory.js +44 -0
- package/dist/databases/database.factory.js.map +1 -0
- package/dist/databases/database.js +9 -0
- package/dist/databases/database.js.map +1 -0
- package/dist/databases/index.d.ts +4 -0
- package/dist/databases/index.d.ts.map +1 -0
- package/dist/databases/index.js +20 -0
- package/dist/databases/index.js.map +1 -0
- package/dist/databases/mysql.database.d.ts +10 -0
- package/dist/databases/mysql.database.d.ts.map +1 -0
- package/dist/databases/mysql.database.js +17 -0
- package/dist/databases/mysql.database.js.map +1 -0
- package/dist/databases/postgres.database.d.ts +10 -0
- package/dist/databases/postgres.database.d.ts.map +1 -0
- package/dist/databases/postgres.database.js +17 -0
- package/dist/databases/postgres.database.js.map +1 -0
- package/dist/pagination.service.d.ts +16 -2
- package/dist/pagination.service.d.ts.map +1 -1
- package/dist/pagination.service.js +131 -5
- package/dist/pagination.service.js.map +1 -1
- package/dist/types/pagination.types.d.ts +1 -0
- package/dist/types/pagination.types.d.ts.map +1 -1
- package/dist/types/query-option.d.ts +5 -0
- package/dist/types/query-option.d.ts.map +1 -0
- package/dist/types/query-option.js +3 -0
- package/dist/types/query-option.js.map +1 -0
- package/dist/types/relation-n2n-result.d.ts +7 -0
- package/dist/types/relation-n2n-result.d.ts.map +1 -0
- package/dist/types/relation-n2n-result.js +3 -0
- package/dist/types/relation-n2n-result.js.map +1 -0
- package/dist/types/transaction-queries.d.ts +7 -0
- package/dist/types/transaction-queries.d.ts.map +1 -0
- package/dist/types/transaction-queries.js +3 -0
- package/dist/types/transaction-queries.js.map +1 -0
- package/package.json +6 -2
- package/src/databases/abstract.database.ts +833 -0
- package/src/databases/database.factory.ts +26 -0
- package/src/databases/database.ts +4 -0
- package/src/databases/index.ts +3 -0
- package/src/databases/mysql.database.ts +14 -0
- package/src/databases/postgres.database.ts +14 -0
- package/src/pagination.service.ts +216 -12
- package/src/types/pagination.types.ts +1 -0
- package/src/types/query-option.ts +4 -0
- package/src/types/relation-n2n-result.ts +6 -0
- package/src/types/transaction-queries.ts +7 -0
package/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<img src="https://avatars.githubusercontent.com/u/177489127?s=200&v=4" alt="Hedhog Avatar" />
|
5
5
|
</p>
|
6
6
|
|
7
|
-
**Hedhog Pagination** is a powerful and flexible pagination library designed for use with HedHog-based projects. It simplifies the process of paginating data results from your database queries, making it easy to handle large datasets and provide
|
7
|
+
**Hedhog Pagination** is a powerful and flexible pagination library designed for use with HedHog-based projects. It simplifies the process of paginating data results from your database queries, making it easy to handle large datasets and provide user with a smooth and efficient browsing experience.
|
8
8
|
|
9
9
|
## Features
|
10
10
|
|
@@ -25,7 +25,7 @@ npm i @hedhog/pagination
|
|
25
25
|
|
26
26
|
```plaintext
|
27
27
|
pagination/
|
28
|
-
├── dist/ # Compiled JavaScript
|
28
|
+
├── dist/ # Compiled JavaScript file from build
|
29
29
|
├── node_modules/ # Discardable folder with all module dependencies
|
30
30
|
├── src/
|
31
31
|
│ ├── constants/
|
@@ -38,11 +38,11 @@ pagination/
|
|
38
38
|
│ │ └── pagination.enums.ts # Enums for pagination
|
39
39
|
│ ├── types/
|
40
40
|
│ │ └── pagination.types.ts # Type definitions for pagination
|
41
|
-
│ ├── index.ts # Entry point for pagination
|
41
|
+
│ ├── index.ts # Entry point for pagination file
|
42
42
|
│ ├── pagination.module.ts # Module definition for pagination functionalities
|
43
43
|
│ ├── pagination.service.spec.ts # Unit tests for PaginationService
|
44
44
|
│ └── pagination.service.ts # Service class for pagination logic
|
45
|
-
├── .gitignore # Specifies which
|
45
|
+
├── .gitignore # Specifies which file Git should ignore
|
46
46
|
├── package.json # Manages dependencies and scripts for the library
|
47
47
|
├── package-lock.json # Lock file for dependencies
|
48
48
|
├── README.md # Documentation for the library
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { DataSource } from 'typeorm';
|
2
|
+
import { QueryOption } from '../types/query-option';
|
3
|
+
import { RelationN2NResult } from '../types/relation-n2n-result';
|
4
|
+
import { TransactionQueries } from '../types/transaction-queries';
|
5
|
+
import { Database } from './database';
|
6
|
+
import EventEmitter = require('events');
|
7
|
+
export declare class AbstractDatabase {
|
8
|
+
protected type: Database;
|
9
|
+
protected host: string;
|
10
|
+
protected user: string;
|
11
|
+
protected password: string;
|
12
|
+
protected database: string;
|
13
|
+
protected port: number;
|
14
|
+
private client;
|
15
|
+
private foreignKeys;
|
16
|
+
private foreignKeysByTable;
|
17
|
+
private primaryKeys;
|
18
|
+
private columnNameFromRelation;
|
19
|
+
private relationN2N;
|
20
|
+
private relation1N;
|
21
|
+
private columnComment;
|
22
|
+
private tableHasColumnOrder;
|
23
|
+
private eventEmitter;
|
24
|
+
private autoClose;
|
25
|
+
constructor(type: Database, host: string, user: string, password: string, database: string, port: number);
|
26
|
+
getDataSource(): DataSource;
|
27
|
+
disableAutoClose(): void;
|
28
|
+
close(): any;
|
29
|
+
on(event: string, listener: (...args: any[]) => void): EventEmitter<[never]>;
|
30
|
+
getArrayType(values: any[]): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
31
|
+
getWhereWithIn(columnName: string, operator: 'in' | 'nin', values: string[] | number[]): string;
|
32
|
+
static addSimpleQuotes(value: any): string;
|
33
|
+
private replacePlaceholders;
|
34
|
+
getColumnNameWithScaping(columnName: string): string;
|
35
|
+
getLimit(offset: number, limit: number): string;
|
36
|
+
getTableNameFromQuery(query: string): string | null;
|
37
|
+
hasTableColumnOrder(tableName: string): Promise<any>;
|
38
|
+
getColumnComment(tableName: string, columnName: string): Promise<any>;
|
39
|
+
getTableNameFromForeignKey(tableName: string, foreignKey: string): Promise<string>;
|
40
|
+
private shouldHandleReturning;
|
41
|
+
private isReturningSingleField;
|
42
|
+
private isReturningIdWithoutPrimaryKeys;
|
43
|
+
private isMissingPrimaryKeys;
|
44
|
+
private hasPrimaryKeys;
|
45
|
+
private hasReturning;
|
46
|
+
private formatOptions;
|
47
|
+
private addReturningToQuery;
|
48
|
+
private getResult;
|
49
|
+
getClient(): Promise<any>;
|
50
|
+
testDatabaseConnection(): Promise<boolean>;
|
51
|
+
getPrimaryKeys(tableName: string): Promise<string[]>;
|
52
|
+
getForeignKeys(tableName: string): Promise<string[]>;
|
53
|
+
getColumnNameFromRelation(tableNameOrigin: string, tableNameDestination: string): Promise<any>;
|
54
|
+
getRelation1N(tableNameOrigin: string, tableNameDestination: string): Promise<string>;
|
55
|
+
getRelationN2N(tableNameOrigin: string, tableNameDestination: string): Promise<RelationN2NResult>;
|
56
|
+
static parseQueryValue(value: any): string | number | boolean;
|
57
|
+
static objectToWhereClause(obj: any): string;
|
58
|
+
transaction(queries: TransactionQueries[]): Promise<any[]>;
|
59
|
+
query(query: string, values?: any[], options?: QueryOption): Promise<any>;
|
60
|
+
}
|
61
|
+
//# sourceMappingURL=abstract.database.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"abstract.database.d.ts","sourceRoot":"","sources":["../../src/databases/abstract.database.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,YAAY,GAAG,QAAQ,QAAQ,CAAC,CAAC;AAExC,qBAAa,gBAAgB;IAczB,SAAS,CAA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