@sourceloop/reporting-service / Exports / PsqlSequelizeStrategy
Class: PsqlSequelizeStrategy¶
Hierarchy¶
-
↳
PsqlSequelizeStrategy
Table of contents¶
Constructors¶
Properties¶
Methods¶
- applyRowLevelFilter
- checkIfColumnsExists
- checkIfDataSourceExists
- deleteRecord
- generateColumnForTable
- getSchemaAndTable
- listDataSourceColumns
- listdataSources
- manageRecord
- query
- sanitizeValue
- translateQuery
- upsertRecord
Constructors¶
constructor¶
• new PsqlSequelizeStrategy(sequelizeObj, logger, queryUtility)
Parameters¶
| Name | Type |
|---|---|
sequelizeObj |
Sequelize |
logger |
ILogger |
queryUtility |
QueryUtilityInterface |
Overrides¶
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:21
Properties¶
logger¶
• logger: ILogger
Inherited from¶
Defined in¶
services/reporting-service/src/strategies/sequelize/base-sequelize.ts:16
queryUtil¶
• queryUtil: QueryUtilityInterface
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:20
sequelize¶
• sequelize: Sequelize
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:19
sequilizeQuertUtility¶
• sequilizeQuertUtility: QueryUtilityInterface
Inherited from¶
BaseSequelize.sequilizeQuertUtility
Defined in¶
services/reporting-service/src/strategies/sequelize/base-sequelize.ts:17
Methods¶
applyRowLevelFilter¶
▸ applyRowLevelFilter(initialQuery): Promise<StructuredQueryInterface>
The function applies a row-level filter to a query and returns the modified query.
Parameters¶
| Name | Type | Description |
|---|---|---|
initialQuery |
StructuredQueryInterface |
The initialQuery parameter is an instance of the StructuredQueryInterface. It represents the initial query that you want to apply a row-level filter to. |
Returns¶
Promise<StructuredQueryInterface>
The initialQuery is being returned.
Overrides¶
BaseSequelize.applyRowLevelFilter
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:196
checkIfColumnsExists¶
▸ checkIfColumnsExists(columnEntityPairs): Promise<boolean>
The function checkIfColumnsExists checks if a list of column-entity pairs exists in the
database.
Parameters¶
| Name | Type | Description |
|---|---|---|
columnEntityPairs |
ColumnEntityPair[] |
An array of objects, where each object represents a pair of column and entity. Each object should have the following properties: |
Returns¶
Promise<boolean>
The function checkIfColumnsExists returns a Promise that resolves to a boolean value.
Overrides¶
BaseSequelize.checkIfColumnsExists
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:158
checkIfDataSourceExists¶
▸ checkIfDataSourceExists(dataSourceNames): Promise<boolean>
The function checkIfDataSourceExists checks if a list of data source names exist in the
database.
Parameters¶
| Name | Type | Description |
|---|---|---|
dataSourceNames |
string[] |
An array of strings representing the names of the data sources to check. |
Returns¶
Promise<boolean>
The function checkIfDataSourceExists returns a Promise that resolves to a boolean
value.
Overrides¶
BaseSequelize.checkIfDataSourceExists
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:124
deleteRecord¶
▸ Private deleteRecord(dataSource, data, identifier): Promise<AnyObject>
The deleteRecord function deletes a record from a specified data source using the provided
identifier.
Parameters¶
| Name | Type | Description |
|---|---|---|
dataSource |
string |
The dataSource parameter is a string that represents the name of the table or data source from which the record needs to be deleted. |
data |
IngestReportRecord |
The data parameter is an object that represents the change data capture (CDC) for a record. It contains the current value of the record being deleted. |
identifier |
string |
The identifier parameter is a string that represents the column name in the database table that uniquely identifies a record. It is used in the WHERE clause of the delete query to specify which record(s) should be deleted. |
Returns¶
Promise<AnyObject>
an object with a property "affectedRecords" which contains the result of the delete operation.
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:301
generateColumnForTable¶
▸ generateColumnForTable(result): Promise<ColumnForDataSourceModel[]>
The function generates columns for a table by converting the data types and mapping the column properties.
Parameters¶
| Name | Type | Description |
|---|---|---|
result |
AnyObject |
An array of objects representing the result of a database query. Each object in the array should have the following properties: |
Returns¶
Promise<ColumnForDataSourceModel[]>
The function generateColumnForTable returns a promise that resolves to an array of
ColumnForDataSourceModel objects.
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:353
getSchemaAndTable¶
▸ getSchemaAndTable(dataSourceName): Object
Parameters¶
| Name | Type |
|---|---|
dataSourceName |
string |
Returns¶
Object
| Name | Type |
|---|---|
schema |
string |
tableName |
string |
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:340
listDataSourceColumns¶
▸ listDataSourceColumns(dataSource): Promise<ColumnForDataSourceModel[]>
The function listDataSourceColumns retrieves column information for a given data source using a
SQL query.
Parameters¶
| Name | Type | Description |
|---|---|---|
dataSource |
string |
The dataSource parameter is a string that represents the name of the data source or table from which you want to fetch the columns. |
Returns¶
Promise<ColumnForDataSourceModel[]>
a Promise that resolves to an array of objects of type ColumnForDataSourceModel.
Overrides¶
BaseSequelize.listDataSourceColumns
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:92
listdataSources¶
▸ listdataSources(): Promise<DataSourceList[]>
The function "listdataSources" retrieves a list of table names and schemas from the database and returns them as an array of DataSourceList objects.
Returns¶
Promise<DataSourceList[]>
The function listdataSources returns a Promise that resolves to an array of objects of
type DataSourceList.
Overrides¶
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:40
manageRecord¶
▸ manageRecord(dataSource, data, identifier?): Promise<AnyObject>
The function manageRecord handles different operations (INSERT, UPDATE, DELETE) on a given data
source using a specified identifier.
Parameters¶
| Name | Type | Default value | Description |
|---|---|---|---|
dataSource |
string |
undefined |
A string representing the data source where the record will be managed. This could be a database table, a file, or any other source of data. |
data |
IngestReportRecord |
undefined |
The data parameter is an object that represents a change in the data. It typically contains the following properties: |
identifier? |
string |
'id' |
The identifier parameter is a string that represents the unique identifier for the record in the data source. It is used to identify the record that needs to be updated or deleted. |
Returns¶
Promise<AnyObject>
The manageRecord function returns a Promise that resolves to an AnyObject object.
Overrides¶
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:213
query¶
▸ query(queryObject): Promise<AnyObject[]>
The function query executes a SQL query using Sequelize and returns the result as an array of
objects.
Parameters¶
| Name | Type | Description |
|---|---|---|
queryObject |
StructuredQueryInterface |
The queryObject parameter is an object that represents a structured query. It contains information such as the table to query, the columns to select, the conditions to filter the data, and any other relevant query parameters. |
Returns¶
Promise<AnyObject[]>
The function query returns a promise that resolves to an array of AnyObject objects.
Overrides¶
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:70
sanitizeValue¶
▸ sanitizeValue(value): JSONValueType
Parameters¶
| Name | Type |
|---|---|
value |
JSONValueType |
Returns¶
Inherited from¶
Defined in¶
services/reporting-service/src/strategies/sequelize/base-sequelize.ts:23
translateQuery¶
▸ translateQuery(queryObject): Promise<{ bind: AnyObject ; query: string }>
Parameters¶
| Name | Type |
|---|---|
queryObject |
StructuredQueryInterface |
Returns¶
Promise<{ bind: AnyObject ; query: string }>
Inherited from¶
Defined in¶
services/reporting-service/src/strategies/sequelize/base-sequelize.ts:53
upsertRecord¶
▸ Private upsertRecord(dataSource, data, identifier?): Promise<AnyObject>
The upsertRecord function inserts or updates a record in a specified data source using the
provided data, with support for sanitization and conflict resolution.
Parameters¶
| Name | Type | Default value | Description |
|---|---|---|---|
dataSource |
string |
undefined |
The dataSource parameter is a string that represents the name of the table or data source where the record will be inserted or updated. |
data |
IngestReportRecord |
undefined |
The data parameter is an object that represents the data to be upserted into the database. It should have a property called currentValue which contains the actual data to be inserted or updated. |
identifier? |
string |
'id' |
The identifier parameter is a string that specifies the column name used as the identifier for upserting records. In the code, it is set to 'id' by default, but you can provide a different column name if needed. |
Returns¶
Promise<AnyObject>
an object with a property "affectedRecords" which contains the result of the upsert operation.
Defined in¶
services/reporting-service/src/strategies/sequelize/psql-sequelize-strategy.ts:245