Skip to content

Commit

Permalink
Refactor database queries to use destructuring for existing pages and…
Browse files Browse the repository at this point in the history
… improve connection pool initialization
  • Loading branch information
PieterDePauw committed Nov 13, 2024
1 parent 52cf324 commit 0acb375
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94578,7 +94578,13 @@ function generateEmbeddings(_a) {
const openaiClient = createOpenAI({ apiKey: openaiApiKey, compatibility: "strict" });
// const client = createClient({ connectionString: databaseUrl })
// const db = drizzle(client)
const pool = createPool({ connectionString: databaseUrl, max: 1, ssl: { rejectUnauthorized: false } });
// Create a connection pool to the database
const pool = createPool({
connectionString: databaseUrl,
ssl: { rejectUnauthorized: false },
max: 1,
});
// Create a Drizzle instance
const db = drizzle(pool);
const refreshVersion = esm_v4();
const refreshDate = new Date();
Expand All @@ -94593,7 +94599,7 @@ function generateEmbeddings(_a) {
console.log(`Discovered ${sources.length} pages.`);
for (const source of sources) {
try {
const existingPage = (yield db.select().from(pages).where(eq(pages.path, source.path)).limit(1))[0];
const [existingPage] = yield db.select().from(pages).where(eq(pages.path, source.path)).limit(1);
// const existingPageId: string = existingPage?.id
const newId = esm_v4();
const pageData = {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function generateEmbeddings({ databaseUrl, openaiApiKey, docsRootPath }: {

for (const source of sources) {
try {
const existingPage = (await db.select().from(documents).where(eq(documents.path, source.path)).limit(1))[0]
const [existingPage] = await db.select().from(documents).where(eq(documents.path, source.path)).limit(1)
// const existingPageId: string = existingPage?.id

const newId: string = uuidv4()
Expand Down

0 comments on commit 0acb375

Please sign in to comment.