Comments (2)
pgvector
does support Slonik.
https://github.com/pgvector/pgvector-node/?tab=readme-ov-file#slonik
from slonik.
This must be why I have not been able to make progress after my first few hours with slonik
.
I create a table with
await pool.connect(async connection =>
{
// We just created a new database so we do not need `IF NOT EXISTS` for any of these entities
await connection.query(sql.unsafe`CREATE EXTENSION vector`);
/// MEM CONTENT
await connection.query(sql.unsafe`CREATE TABLE mem(
id BIGINT PRIMARY KEY, -- bun.hash
content TEXT NOT NULL,
embed_vector vector(768) NOT NULL,
tssearch tsvector GENERATED ALWAYS AS (to_tsvector('english', content)) STORED,
tokens INT NOT NULL)`
);
}
And then I try to insert data with
async function createMem(content: string) : Promise<Mem> {
const mem: Mem = Mem.parse({
id: BigInt(Bun.hash(content)),
content: content,
embed_vector: await embedding.generateOne(content),
tokens: count_tokens(content)
})
return mem;
}
return await pool.connect(async connection => {
// A Mem is entirely determined from its content, so we only pass in the content to this function,
// and then construct the Mem from the content.
const mem: Mem = await createMem(content);
try {
const insertMemQuery = sql.type(Mem)`
INSERT INTO mem (id, content, embed_vector, tokens)
VALUES (${mem.id}, ${mem.content}, ${mem.embed_vector}, ${mem.tokens})`;
await connection.query(insertMemQuery);
// TODO validate result
} catch (err) {
console.error((err as Error).stack)
throw err;
}
I get this error:
Error: Expected token to include "type" property.
at isSqlToken (/Users/jim.lloyd/hub/Memento/node_modules/slonik/dist/utilities/isSqlToken.js:29:14)
at createFragment (/Users/jim.lloyd/hub/Memento/node_modules/slonik/dist/factories/createSqlTag.js:39:22)
at <anonymous> (/Users/jim.lloyd/hub/Memento/node_modules/slonik/dist/factories/createSqlTag.js:135:20)
at <anonymous> (/Users/jim.lloyd/hub/Memento/src/lib/postgresdb.ts:127:30)
at asyncFunctionResume (native)
at promiseReactionJobWithoutPromiseUnwrapAsyncContext (native)
at promiseReactionJob (native)
at processTicksAndRejections (native)
UnexpectedStateError: Expected token to include "type" property.
pgvector
is a requirement for the app I want to build. slonik
looks very cool but perhaps I have to find some other alternative? Is there a workaround until this issue is addressed?
from slonik.
Related Issues (20)
- Breaking change (Node engine update) in patch version 37.0.3 HOT 1
- Partial<>'s Not Valid for SerializableValue HOT 4
- Improving Runtime Validation Performance through Async Parsing HOT 4
- Slonik fails with more than eight statements on one connection HOT 1
- Export MaybePromise from package as its currently missing HOT 1
- libpq-dev required to install dev dependencies HOT 1
- Add support for `options` parameter in connection URLs HOT 2
- Cannot use $1 in nested TEXT HOT 1
- Cannot use $1 or $\d+ in nested SQL fragments HOT 3
- Add ability to avoid nested transaction by detecting DatabasePoolConnection is a transaction HOT 4
- Re-think how we organize error messages
- Remove dependency on roarr and allow for custom logging solution integration HOT 4
- Running multiple SQL commands at once throws an exception HOT 5
- Because many throws when there's no rows it would be nice to have maybeMany HOT 2
- Move middlewares into /slonik codebase
- Slonik Errors override with native errors
- idleTimeout with `DISABLE_TIMEOUT` set will use a 10s timeout
- Prevent unsafe sql.fragment usage
- Can execute multiple statements in a single query HOT 4
- "[unable to serialize, circular reference is too complex to analyze]" inserted into jsonb column HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slonik.