CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
indexes.d.ts80 linesDownload Raw Back to gel-core
1import { SQL } from "../sql/sql.js";2import { entityKind } from "../entity.js";3import type { GelColumn, GelExtraConfigColumn } from "./columns/index.js";4import { IndexedColumn } from "./columns/index.js";5import type { GelTable } from "./table.js";6interface IndexConfig {7    name?: string;8    columns: Partial<IndexedColumn | SQL>[];9    /**10     * If true, the index will be created as `create unique index` instead of `create index`.11     */12    unique: boolean;13    /**14     * If true, the index will be created as `create index concurrently` instead of `create index`.15     */16    concurrently?: boolean;17    /**18     * If true, the index will be created as `create index ... on only <table>` instead of `create index ... on <table>`.19     */20    only: boolean;21    /**22     * Condition for partial index.23     */24    where?: SQL;25    /**26     * The optional WITH clause specifies storage parameters for the index27     */28    with?: Record<string, any>;29    /**30     * The optional WITH clause method for the index31     */32    method?: 'btree' | string;33}34export type IndexColumn = GelColumn;35export type GelIndexMethod = 'btree' | 'hash' | 'gist' | 'sGelist' | 'gin' | 'brin' | 'hnsw' | 'ivfflat' | (string & {});36export type GelIndexOpClass = 'abstime_ops' | 'access_method' | 'anyarray_eq' | 'anyarray_ge' | 'anyarray_gt' | 'anyarray_le' | 'anyarray_lt' | 'anyarray_ne' | 'bigint_ops' | 'bit_ops' | 'bool_ops' | 'box_ops' | 'bpchar_ops' | 'char_ops' | 'cidr_ops' | 'cstring_ops' | 'date_ops' | 'float_ops' | 'int2_ops' | 'int4_ops' | 'int8_ops' | 'interval_ops' | 'jsonb_ops' | 'macaddr_ops' | 'name_ops' | 'numeric_ops' | 'oid_ops' | 'oidint4_ops' | 'oidint8_ops' | 'oidname_ops' | 'oidvector_ops' | 'point_ops' | 'polygon_ops' | 'range_ops' | 'record_eq' | 'record_ge' | 'record_gt' | 'record_le' | 'record_lt' | 'record_ne' | 'text_ops' | 'time_ops' | 'timestamp_ops' | 'timestamptz_ops' | 'timetz_ops' | 'uuid_ops' | 'varbit_ops' | 'varchar_ops' | 'xml_ops' | 'vector_l2_ops' | 'vector_ip_ops' | 'vector_cosine_ops' | 'vector_l1_ops' | 'bit_hamming_ops' | 'bit_jaccard_ops' | 'halfvec_l2_ops' | 'sparsevec_l2_op' | (string & {});37export declare class IndexBuilderOn {38    private unique;39    private name?;40    static readonly [entityKind]: string;41    constructor(unique: boolean, name?: string | undefined);42    on(...columns: [Partial<GelExtraConfigColumn> | SQL, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;43    onOnly(...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;44    /**45     * Specify what index method to use. Choices are `btree`, `hash`, `gist`, `sGelist`, `gin`, `brin`, or user-installed access methods like `bloom`. The default method is `btree.46     *47     * If you have the `Gel_vector` extension installed in your database, you can use the `hnsw` and `ivfflat` options, which are predefined types.48     *49     * **You can always specify any string you want in the method, in case Drizzle doesn't have it natively in its types**50     *51     * @param method The name of the index method to be used52     * @param columns53     * @returns54     */55    using(method: GelIndexMethod, ...columns: [Partial<GelExtraConfigColumn | SQL>, ...Partial<GelExtraConfigColumn | SQL>[]]): IndexBuilder;56}57export interface AnyIndexBuilder {58    build(table: GelTable): Index;59}60export interface IndexBuilder extends AnyIndexBuilder {61}62export declare class IndexBuilder implements AnyIndexBuilder {63    static readonly [entityKind]: string;64    constructor(columns: Partial<IndexedColumn | SQL>[], unique: boolean, only: boolean, name?: string, method?: string);65    concurrently(): this;66    with(obj: Record<string, any>): this;67    where(condition: SQL): this;68}69export declare class Index {70    static readonly [entityKind]: string;71    readonly config: IndexConfig & {72        table: GelTable;73    };74    constructor(config: IndexConfig, table: GelTable);75}76export type GetColumnsTableName<TColumns> = TColumns extends GelColumn ? TColumns['_']['name'] : TColumns extends GelColumn[] ? TColumns[number]['_']['name'] : never;77export declare function index(name?: string): IndexBuilderOn;78export declare function uniqueIndex(name?: string): IndexBuilderOn;79export {};80