2021-09-20 19:15:50 +02:00
|
|
|
import { Database } from '../';
|
|
|
|
import { Action } from '../lifecycles';
|
|
|
|
|
|
|
|
type Type =
|
|
|
|
| 'string'
|
|
|
|
| 'text'
|
|
|
|
| 'richtext'
|
|
|
|
| 'json'
|
|
|
|
| 'enumeration'
|
|
|
|
| 'password'
|
|
|
|
| 'email'
|
|
|
|
| 'integer'
|
|
|
|
| 'biginteger'
|
|
|
|
| 'float'
|
|
|
|
| 'decimal'
|
|
|
|
| 'date'
|
|
|
|
| 'time'
|
|
|
|
| 'datetime'
|
|
|
|
| 'timestamp'
|
|
|
|
| 'boolean'
|
|
|
|
| 'relation';
|
|
|
|
|
|
|
|
export interface Attribute {
|
|
|
|
type: Type;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Model {
|
|
|
|
uid: string;
|
|
|
|
tableName: string;
|
|
|
|
attributes: {
|
|
|
|
id: {
|
|
|
|
type: 'increments';
|
|
|
|
};
|
|
|
|
[k: string]: Attribute;
|
|
|
|
};
|
|
|
|
lifecycles?: {
|
|
|
|
[k in Action]: () => void;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-15 20:48:55 +00:00
|
|
|
export interface SchemaProvider {
|
2021-09-20 19:15:50 +02:00
|
|
|
sync(): Promise<void>;
|
|
|
|
syncSchema(): Promise<void>;
|
|
|
|
reset(): Promise<void>;
|
|
|
|
create(): Promise<void>;
|
|
|
|
drop(): Promise<void>;
|
|
|
|
}
|
|
|
|
|
2022-11-21 17:19:39 +01:00
|
|
|
export default function (db: Database): SchemaProvider;
|