From 66e2f4264658332cba5e2f69cf6b130b2d9ebeb1 Mon Sep 17 00:00:00 2001 From: Skyler Lewis Date: Tue, 12 Sep 2023 15:13:05 -0600 Subject: [PATCH] remove unused code --- src/db/index.ts | 50 --------------------------------------- src/queryBuilder/index.ts | 5 ++++ src/string-literal.ts | 5 ++-- 3 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 src/db/index.ts diff --git a/src/db/index.ts b/src/db/index.ts deleted file mode 100644 index 138f93b..0000000 --- a/src/db/index.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { SqueakqlQuery } from "../query"; - -const getRequestContext = () => { - // TODO: This is a stub, replace this with a real implementation - return { - span: { - startChild: (options: any) => { - return { - setData: (key: string, value: any) => {}, - finish: () => {}, - }; - }, - }, - db: { - query: async (queryStr: SqueakqlQuery, tags: any) => { - return { - rows: [], - }; - }, - transact: async (callback: () => Promise) => { - return await callback(); - }, - }, - }; -}; - -export async function dbQuery(queryStr: SqueakqlQuery): Promise { - const ctx = getRequestContext(); - let tags = { - application: "TODO: INSERT APPLICATION NAME HERE", - route: "TODO: INSERT ROUTE HERE", - }; - let dbSpan; - if (ctx?.span) - dbSpan = ctx.span.startChild({ - description: "TODO: service name", - op: "db.query", - }); - let result = (await ctx.db.query(queryStr, tags)).rows; - if (!dbSpan) { - } else if (queryStr instanceof SqueakqlQuery) - dbSpan.setData("query", queryStr.toString()); - if (dbSpan) dbSpan.finish(); - return result; -} - -export async function dbTransact(callback: () => Promise): Promise { - const ctx = getRequestContext(); - return await ctx.db.transact(callback); -} diff --git a/src/queryBuilder/index.ts b/src/queryBuilder/index.ts index ae680cb..2332b50 100644 --- a/src/queryBuilder/index.ts +++ b/src/queryBuilder/index.ts @@ -10,9 +10,14 @@ export class BaseTable { public joinColumn: string = "id" ) {} } + /** HELPERS */ type Dictionary = Record; +/** + * A class representing a query builder for Squeakql. + * This can only build SELECT queries. + */ export class QueryBuilder { public baseTable: BaseTable; public columns: SqueakqlQuery[] = []; diff --git a/src/string-literal.ts b/src/string-literal.ts index 64e40fd..e9c46a4 100644 --- a/src/string-literal.ts +++ b/src/string-literal.ts @@ -3,7 +3,6 @@ import { arrayEnsure as ensureArray, keyObjArray, } from "../ts-utils/array/array-ensure"; -import { dbQuery } from "./db"; import { objectPrune as pruneObject } from "../ts-utils/object/object-prune"; /** HELPERS */ @@ -98,7 +97,7 @@ sql.updateMany = async < table: string, vals: Dictionary, arrayType?: SqueakqlQuery -): Promise => { +) => { let columns = []; let columns_set = false; let all_vals = []; @@ -139,5 +138,5 @@ sql.updateMany = async < columns.map((c) => sql`:${c}`) )}) WHERE d.id=v.id`; - return await dbQuery(query); + return query; };