src/model/schema/SourceTableInstance.ts
Represents a unique instance of a sourceTable inside a table. Also often referred to as "source".
Properties |
Methods |
|
Accessors |
constructor(table: SourceTable, userAlias?: string)
|
|||||||||
Defined in src/model/schema/SourceTableInstance.ts:10
|
|||||||||
Parameters :
|
Public id |
Type : number
|
Default value : 1
|
Defined in src/model/schema/SourceTableInstance.ts:6
|
Number to append to the baseAlias to enforce that the aliases of sources are unique in one table. |
Public table |
Type : SourceTable
|
Defined in src/model/schema/SourceTableInstance.ts:12
|
Public useId |
Default value : false
|
Defined in src/model/schema/SourceTableInstance.ts:8
|
Returns whether the id is needed to enforce unique source names. |
Public Optional userAlias |
Type : string
|
Defined in src/model/schema/SourceTableInstance.ts:10
|
The alias that the user manually gave to this source. |
Public equals | ||||||
equals(other: SourceTableInstance)
|
||||||
Defined in src/model/schema/SourceTableInstance.ts:36
|
||||||
Parameters :
Returns :
boolean
|
Public setUserAlias | ||||||
setUserAlias(newAlias?: string)
|
||||||
Defined in src/model/schema/SourceTableInstance.ts:31
|
||||||
Parameters :
Returns :
void
|
baseAlias |
getbaseAlias()
|
Defined in src/model/schema/SourceTableInstance.ts:16
|
alias |
getalias()
|
Defined in src/model/schema/SourceTableInstance.ts:21
|
An alias for the source. It is unique in one table. |
defaultName |
getdefaultName()
|
Defined in src/model/schema/SourceTableInstance.ts:27
|
import SourceTable from './SourceTable';
/** Represents a unique instance of a sourceTable inside a table. Also often referred to as "source". */
export default class SourceTableInstance {
/** Number to append to the baseAlias to enforce that the aliases of sources are unique in one table. */
public id = 1;
/** Returns whether the id is needed to enforce unique source names. */
public useId = false;
/** The alias that the user manually gave to this source. */
public userAlias?: string;
constructor(public table: SourceTable, userAlias?: string) {
this.setUserAlias(userAlias);
}
public get baseAlias(): string {
return this.userAlias ?? this.defaultName;
}
/** An alias for the source. It is unique in one table. */
public get alias() {
let alias = this.baseAlias;
if (this.useId) alias += this.id.toString();
return alias;
}
public get defaultName() {
return this.table.name;
}
public setUserAlias(newAlias?: string) {
if (!newAlias || newAlias == this.defaultName) this.userAlias = undefined;
else this.userAlias = newAlias;
}
public equals(other: SourceTableInstance): boolean {
if (this === other) return true;
return this.alias == other.alias;
}
}