-
Notifications
You must be signed in to change notification settings - Fork 181
/
Copy pathcreateOperatorFamily.ts
30 lines (23 loc) · 1 KB
/
createOperatorFamily.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
import type { MigrationOptions } from '../../types';
import type { Name, Reversible } from '../generalTypes';
import type { DropOperatorFamilyOptions } from './dropOperatorFamily';
import { dropOperatorFamily } from './dropOperatorFamily';
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface CreateOperatorFamilyOptions {}
export type CreateOperatorFamilyFn = (
operatorFamilyName: Name,
indexMethod: Name,
operatorFamilyOptions?: CreateOperatorFamilyOptions &
DropOperatorFamilyOptions
) => string;
export type CreateOperatorFamily = Reversible<CreateOperatorFamilyFn>;
export function createOperatorFamily(
mOptions: MigrationOptions
): CreateOperatorFamily {
const _create: CreateOperatorFamily = (operatorFamilyName, indexMethod) => {
const operatorFamilyNameStr = mOptions.literal(operatorFamilyName);
return `CREATE OPERATOR FAMILY ${operatorFamilyNameStr} USING ${indexMethod};`;
};
_create.reverse = dropOperatorFamily(mOptions);
return _create;
}