paaradiso
paaradiso
DTDrizzle Team
Created by paaradiso on 6/12/2024 in #help
NeonDbError: Error connecting to database: fetch failed
i get this ^ error on my laptop which runs linux but not my desktop which runs windows. how do i fix it?
3 replies
DTDrizzle Team
Created by paaradiso on 11/11/2023 in #help
how can i delete if row exists (where eq(xxx)), otherwise insert, in one query?
would i have to use raw sql & an if/else statement?
24 replies
DTDrizzle Team
Created by paaradiso on 11/9/2023 in #help
how to do the opposite of inArray()?
i'm getting all collections (music single, ep, or album) that contain a certain tag. currently i'm doing this:
const chosenTagCollectionIDs = tagMap.get(tag);

const collections = await getCollections({
where: inArray(collectionsTable.id, chosenTagCollectionIDs),
sort: true
});
const chosenTagCollectionIDs = tagMap.get(tag);

const collections = await getCollections({
where: inArray(collectionsTable.id, chosenTagCollectionIDs),
sort: true
});
where chosenTagCollectionIDs is a list of collection ids that have the tag i'm looking for. collectionsTable.tags is a list of tags. can i somehow use inArray() to check if the collectionsTable.tags array contains tag?
7 replies
DTDrizzle Team
Created by paaradiso on 11/9/2023 in #help
TypeError: client.unsafe is not a function with neon
i get this error only when using the neon driver. with normal postgres, it works normally.
1 replies
DTDrizzle Team
Created by paaradiso on 11/8/2023 in #help
Cannot read properties of undefined (reading 'referencedTable')
i'm just playing around with queries and i can't get this to work:
const liked = await db.query.collectionsTable.findMany({
with: {
likedCollectionsTable: true
}
});
const liked = await db.query.collectionsTable.findMany({
with: {
likedCollectionsTable: true
}
});
without the with it works. i'm passing the schemas to the db object:
export const db = drizzle(queryClient, { schema });
export const db = drizzle(queryClient, { schema });
and here are the two schemas:
export const likedCollectionsTable = pgTable('liked_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});

export const collectionsTable = pgTable('collections', {
id: integer('id').primaryKey(),
name: text('name'),
type: collectionTypeEnum('type'),
cover: text('cover'),
artist: text('artist'),
tags: text('tags')
.references(() => tagsTable.name)
.array(),
releaseDate: date('release_date'),
addedBy: text('added_by')
});
export const likedCollectionsTable = pgTable('liked_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});

export const collectionsTable = pgTable('collections', {
id: integer('id').primaryKey(),
name: text('name'),
type: collectionTypeEnum('type'),
cover: text('cover'),
artist: text('artist'),
tags: text('tags')
.references(() => tagsTable.name)
.array(),
releaseDate: date('release_date'),
addedBy: text('added_by')
});
12 replies
DTDrizzle Team
Created by paaradiso on 11/8/2023 in #help
Key columns "user_id" and "id" are of incompatible types: text and bigint.
I'm getting the error in the title ^ but they're the same type.
export const usersTable = pgTable('users', {
id: text('id').primaryKey()
});

export const likedCollectionsTable = pgTable('liked_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});

export const recommendedCollectionsTable = pgTable('recommended_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});
export const usersTable = pgTable('users', {
id: text('id').primaryKey()
});

export const likedCollectionsTable = pgTable('liked_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});

export const recommendedCollectionsTable = pgTable('recommended_collections', {
userId: text('user_id').references(() => usersTable.id),
collection_id: integer('collection_id').references(() => collectionsTable.id)
});
6 replies