CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
schema.js48 linesDownload Raw Back to gel-core
1import { entityKind, is } from "../entity.js";2import { SQL, sql } from "../sql/sql.js";3import { gelSequenceWithSchema } from "./sequence.js";4import { gelTableWithSchema } from "./table.js";5class GelSchema {6  constructor(schemaName) {7    this.schemaName = schemaName;8  }9  static [entityKind] = "GelSchema";10  table = (name, columns, extraConfig) => {11    return gelTableWithSchema(name, columns, extraConfig, this.schemaName);12  };13  // view = ((name, columns) => {14  // 	return gelViewWithSchema(name, columns, this.schemaName);15  // }) as typeof gelView;16  // materializedView = ((name, columns) => {17  // 	return gelMaterializedViewWithSchema(name, columns, this.schemaName);18  // }) as typeof gelMaterializedView;19  // enum: typeof gelEnum = ((name, values) => {20  // 	return gelEnumWithSchema(name, values, this.schemaName);21  // });22  sequence = (name, options) => {23    return gelSequenceWithSchema(name, options, this.schemaName);24  };25  getSQL() {26    return new SQL([sql.identifier(this.schemaName)]);27  }28  shouldOmitSQLParens() {29    return true;30  }31}32function isGelSchema(obj) {33  return is(obj, GelSchema);34}35function gelSchema(name) {36  if (name === "public") {37    throw new Error(38      `You can't specify 'public' as schema name. Postgres is using public schema by default. If you want to use 'public' schema, just use GelTable() instead of creating a schema`39    );40  }41  return new GelSchema(name);42}43export {44  GelSchema,45  gelSchema,46  isGelSchema47};48//# sourceMappingURL=schema.js.map