dblang/src/types.ts

59 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-01-23 21:19:18 +01:00
import { Attribute, Table } from "./db";
2023-01-29 22:11:24 +01:00
import { Aggregation, BooleanModifier, Datatype, Joins, Modifier } from "./dbStructure";
2023-02-13 23:44:08 +01:00
import { QueryBuilder, selectQuery } from "./query";
2023-01-23 21:19:18 +01:00
export type primaryData = string | number | boolean | null;
export type allModifierInput = primaryData | Modifier | selectQuery | Attribute | Aggregation;
export type selectElements = primaryData | Attribute | Aggregation | selectQuery
export type selectFromElements = Table | Joins | null;
2023-02-15 13:58:19 +01:00
export type joinElements = Table | Joins;
2023-01-23 21:19:18 +01:00
export type serializeReturn = [string, primaryData[]];
2023-02-13 23:44:08 +01:00
export type DatatypeBuild = [QueryBuilder, number];
2023-01-24 10:40:16 +01:00
export type attributeSettings = {
unique?: boolean,
2023-01-24 20:34:03 +01:00
autoIncrement?: boolean,
2023-01-24 10:40:16 +01:00
default?: primaryData,
notNull?: boolean
primaryKey?: boolean,
foreginKey?: {
link: Attribute,
onDelete?: onAction,
onUpdate?: onAction
2023-01-29 22:11:24 +01:00
},
2023-02-13 23:44:08 +01:00
check?: BooleanModifier | ((a: Attribute) => BooleanModifier)
2023-01-24 10:40:16 +01:00
};
2023-02-13 23:44:08 +01:00
2023-01-29 22:11:24 +01:00
export type extendedAttributeSettings = {
type: Datatype,
unique?: boolean,
autoIncrement?: boolean,
default?: primaryData,
notNull?: boolean
primaryKey?: boolean,
foreginKey?: {
link: Attribute,
onDelete?: onAction,
onUpdate?: onAction
},
2023-02-13 23:44:08 +01:00
check?: BooleanModifier | ((a: Attribute) => BooleanModifier)
2023-01-29 22:11:24 +01:00
}
2023-01-23 21:19:18 +01:00
2023-01-23 22:10:33 +01:00
export enum onAction {
2023-02-14 17:37:01 +01:00
nothing,
2023-01-23 21:19:18 +01:00
cascade,
noAction,
setNull,
setDefault
2023-01-29 22:11:24 +01:00
}
2023-02-15 13:58:19 +01:00
export enum joinType {
inner,
left,
right,
full,
cross
}