-
Notifications
You must be signed in to change notification settings - Fork 0
Mutation handling #3
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,9 +2,9 @@ FROM node:16-alpine | |
|
|
||
| WORKDIR /app | ||
| COPY package.json . | ||
| COPY package-lock.json . | ||
| # COPY package-lock.json . | ||
|
|
||
| RUN npm ci --include=dev | ||
| RUN npm i --include=dev | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing Switching from |
||
|
|
||
| COPY tsconfig.json . | ||
| COPY nodemon.json . | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||
| ColumnInsertFieldValue, | ||||||||||||||||||||||||||||||||||||||||
| MutationRequest, | ||||||||||||||||||||||||||||||||||||||||
| MutationResponse, | ||||||||||||||||||||||||||||||||||||||||
| QueryRequest, | ||||||||||||||||||||||||||||||||||||||||
| QueryResponse, | ||||||||||||||||||||||||||||||||||||||||
| } from "@hasura/dc-api-types"; | ||||||||||||||||||||||||||||||||||||||||
| import { Config } from "../config"; | ||||||||||||||||||||||||||||||||||||||||
| import def from "ajv/dist/vocabularies/discriminator"; | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Importing - import def from "ajv/dist/vocabularies/discriminator";Remove the unused import to clean up the code and reduce confusion. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| import { builtInPropertiesKeys } from "./collections"; | ||||||||||||||||||||||||||||||||||||||||
| import { getQdrantClient } from "../qdrant"; | ||||||||||||||||||||||||||||||||||||||||
| import { executeQueryById } from "./query"; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| export async function executeMutation( | ||||||||||||||||||||||||||||||||||||||||
| mutation: MutationRequest, | ||||||||||||||||||||||||||||||||||||||||
| config: Config | ||||||||||||||||||||||||||||||||||||||||
| ): Promise<MutationResponse> { | ||||||||||||||||||||||||||||||||||||||||
| const response: MutationResponse = { | ||||||||||||||||||||||||||||||||||||||||
| operation_results: [], | ||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||
| const qdrantClient = getQdrantClient(config); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| for (const operation of mutation.operations) { | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| switch (operation.type) { | ||||||||||||||||||||||||||||||||||||||||
| case "insert": | ||||||||||||||||||||||||||||||||||||||||
| // construct list of points | ||||||||||||||||||||||||||||||||||||||||
| let points: any = []; | ||||||||||||||||||||||||||||||||||||||||
| for (const row of operation.rows) { | ||||||||||||||||||||||||||||||||||||||||
| points.push({ | ||||||||||||||||||||||||||||||||||||||||
| id: Number(row.id), | ||||||||||||||||||||||||||||||||||||||||
| vector: JSON.parse(row.vector as string), | ||||||||||||||||||||||||||||||||||||||||
| payload: JSON.parse(row.payload as string), | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Parsing Directly parsing |
||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+28
to
+34
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using Consider defining a more specific type or interface for the - let points: any = [];
+ interface Point {
+ id: number;
+ vector: any; // Consider defining a more specific type
+ payload: any; // Consider defining a more specific type
+ }
+ let points: Point[] = [];Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| await qdrantClient.upsert(operation.table[0], {points: points}); | ||||||||||||||||||||||||||||||||||||||||
| response.operation_results.push({ | ||||||||||||||||||||||||||||||||||||||||
| affected_rows: operation.rows.length, | ||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No error handling for The |
||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||
| case "delete": | ||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,7 @@ async function executeQueryAll(table: string, query: Query, config: Config) { | |
|
|
||
|
|
||
|
|
||
| async function executeQueryById( | ||
| export async function executeQueryById( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removal of The removal of |
||
| id: string, | ||
| table: string, | ||
| query: Query, | ||
|
|
@@ -107,7 +107,6 @@ async function executeQueryById( | |
|
|
||
|
|
||
| function expressionQueryType(query: any){ | ||
| console.log(query); | ||
| switch (query.where.value.value_type) { | ||
| case "uuid": | ||
| return Number(query.where.value.value); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting out the
COPY package-lock.json .line.Removing
package-lock.jsonfrom the Docker build context can lead to non-deterministic builds becausenpm iwill install the latest versions of dependencies, potentially introducing breaking changes. Consider usingnpm ciinstead ofnpm ifor more reliable builds, which requirespackage-lock.json.