Skip to content

Commit

Permalink
add missing prisma filter operators (#3321)
Browse files Browse the repository at this point in the history
  • Loading branch information
Njuelle authored Nov 19, 2023
1 parent 0157a89 commit b29f0a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/core_docs/docs/integrations/vectorstores/prisma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ import Schema from "@examples/indexes/vector_stores/prisma_vectorstore/prisma/sc

<CodeBlock language="typescript">{Example}</CodeBlock>

The following SQL operators are available as filters: `equals`, `in`, `lt`, `lte`, `gt`, `gte`, `not`.
The following SQL operators are available as filters: `equals`, `in`, `isNull`, `isNotNull`, `like`, `lt`, `lte`, `gt`, `gte`, `not`.

The samples above uses the following schema:

Expand Down
9 changes: 9 additions & 0 deletions langchain/src/vectorstores/prisma.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export type PrismaSqlFilter<TModel extends Record<string, unknown>> = {
[K in keyof TModel]?: {
equals?: TModel[K];
in?: TModel[K][];
isNull?: TModel[K];
isNotNull?: TModel[K];
like?: TModel[K];
lt?: TModel[K];
lte?: TModel[K];
gt?: TModel[K];
Expand All @@ -73,6 +76,9 @@ export type PrismaSqlFilter<TModel extends Record<string, unknown>> = {
const OpMap = {
equals: "=",
in: "IN",
isNull: "IS NULL",
isNotNull: "IS NOT NULL",
like: "LIKE",
lt: "<",
lte: "<=",
gt: ">",
Expand Down Expand Up @@ -432,6 +438,9 @@ export class PrismaVectorStore<
}
return this.Prisma.sql`${colRaw} ${opRaw} (${value.join(",")})`;
}
case OpMap.isNull:
case OpMap.isNotNull:
return this.Prisma.sql`${colRaw} ${opRaw}`;
default:
return this.Prisma.sql`${colRaw} ${opRaw} ${value}`;
}
Expand Down

1 comment on commit b29f0a5

@vercel
Copy link

@vercel vercel bot commented on b29f0a5 Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

langchainjs-docs – ./docs/core_docs/

langchainjs-docs-git-main-langchain.vercel.app
js.langchain.com
langchainjs-docs-ruddy.vercel.app
langchainjs-docs-langchain.vercel.app

Please sign in to comment.