-
Notifications
You must be signed in to change notification settings - Fork 70
/
ingestion-mappings.service.ts
77 lines (77 loc) · 3.35 KB
/
ingestion-mappings.service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import {BindingScope, injectable} from '@loopback/core';
import {Count, repository} from '@loopback/repository';
import {IngestionMapping} from '../models/ingestion-mapping.model';
import {IngestionMappingsRepository} from '../repositories/ingestion-mappings.repository';
@injectable({scope: BindingScope.TRANSIENT})
export class IngestionMappingsService {
constructor(
@repository(IngestionMappingsRepository)
private readonly ingestionMappingsRepository: IngestionMappingsRepository,
) {}
/**
* The function `deleteByName` deletes a record from the `ingestionMappingsRepository` based on the
* provided `dataSourceName`.
* @param {string} dataSourceName - The parameter `dataSourceName` is a string that represents the
* name of the data source to be deleted.
* @returns either void or a Promise that resolves to void.
*/
deleteByName(dataSourceName: string): void | PromiseLike<void> {
return this.ingestionMappingsRepository.deleteById(dataSourceName);
}
/**
* The function "getByName" retrieves ingestion mappings by their data source name.
* @param {string} dataSourceName - A string representing the name of the data source.
* @returns either an IngestionMappings object or a Promise that resolves to an IngestionMappings
* object.
*/
getByName(
dataSourceName: string,
): IngestionMapping | Promise<IngestionMapping> {
return this.ingestionMappingsRepository.findById(dataSourceName);
}
/**
* The function `getAll` returns a promise that resolves to an array of `IngestionMappings` objects.
* @returns The getAll() function is returning a Promise that resolves to an array of
* IngestionMappings objects.
*/
getAll(): Promise<IngestionMapping[]> {
return this.ingestionMappingsRepository.find();
}
/**
* The function updates an ingestion mapping object in a data source repository.
* @param {string} dataSourceName - A string representing the name of the data source.
* @param {IngestionMapping} IngestionMapObj - The IngestionMapObj parameter is an object that
* contains the ingestion mappings for a data source. It is used to update the ingestion mappings
* in the repository.
* @returns a Promise that resolves to void.
*/
update(
dataSourceName: string,
ingestionMapObj: IngestionMapping,
): Promise<void> {
return this.ingestionMappingsRepository.updateById(
dataSourceName,
ingestionMapObj,
);
}
/**
* The function creates an ingestion mapping object and returns it or a promise of it.
* @param {IngestionMapping} IngestionMapObj - An object that contains the mappings for ingestion.
* It could include properties such as source fields and their corresponding destination fields,
* data transformations, and any other relevant information for the ingestion process.
* @returns either an IngestionMappings object or a Promise that resolves to an IngestionMappings
* object.
*/
create(
ingestionMapObj: IngestionMapping,
): IngestionMapping | Promise<IngestionMapping> {
return this.ingestionMappingsRepository.create(ingestionMapObj);
}
/**
* The `getCount` function returns a promise that resolves to the count of ingestion mappings.
* @returns The `getCount()` function is returning a Promise that resolves to a `Count` object.
*/
getCount(): Promise<Count> {
return this.ingestionMappingsRepository.count();
}
}