CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
driver.cjs68 linesDownload Raw Back to op-sqlite
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var driver_exports = {};20__export(driver_exports, {21  OPSQLiteDatabase: () => OPSQLiteDatabase,22  drizzle: () => drizzle23});24module.exports = __toCommonJS(driver_exports);25var import_entity = require("../entity.cjs");26var import_logger = require("../logger.cjs");27var import_relations = require("../relations.cjs");28var import_db = require("../sqlite-core/db.cjs");29var import_dialect = require("../sqlite-core/dialect.cjs");30var import_session = require("./session.cjs");31class OPSQLiteDatabase extends import_db.BaseSQLiteDatabase {32  static [import_entity.entityKind] = "OPSQLiteDatabase";33}34function drizzle(client, config = {}) {35  const dialect = new import_dialect.SQLiteAsyncDialect({ casing: config.casing });36  let logger;37  if (config.logger === true) {38    logger = new import_logger.DefaultLogger();39  } else if (config.logger !== false) {40    logger = config.logger;41  }42  let schema;43  if (config.schema) {44    const tablesConfig = (0, import_relations.extractTablesRelationalConfig)(45      config.schema,46      import_relations.createTableRelationsHelpers47    );48    schema = {49      fullSchema: config.schema,50      schema: tablesConfig.tables,51      tableNamesMap: tablesConfig.tableNamesMap52    };53  }54  const session = new import_session.OPSQLiteSession(client, dialect, schema, { logger, cache: config.cache });55  const db = new OPSQLiteDatabase("async", dialect, session, schema);56  db.$client = client;57  db.$cache = config.cache;58  if (db.$cache) {59    db.$cache["invalidate"] = config.cache?.onMutate;60  }61  return db;62}63// Annotate the CommonJS export names for ESM import in node:640 && (module.exports = {65  OPSQLiteDatabase,66  drizzle67});68//# sourceMappingURL=driver.cjs.map