Liltripple_reid
Liltripple_reid
Explore posts from servers
DTDrizzle Team
Created by Liltripple_reid on 10/13/2024 in #help
Unable to use `push` or `studio` anymore
after reviewing the error message I was using a .tsx extension in a file used by drizzle which somehow caused it to die
6 replies
DTDrizzle Team
Created by Liltripple_reid on 10/13/2024 in #help
Unable to use `push` or `studio` anymore
update: it wasn't
6 replies
DTDrizzle Team
Created by Liltripple_reid on 10/13/2024 in #help
Unable to use `push` or `studio` anymore
think so in that case
6 replies
DTDrizzle Team
Created by Liltripple_reid on 10/13/2024 in #help
Unable to use `push` or `studio` anymore
this is the config I've been using since the start of my project
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
dialect: "sqlite",
driver: "turso",
verbose: true,
dbCredentials: {
url: env.DATABASE_URL,
authToken: env.AUTH_TOKEN,
},
} satisfies Config;
import { type Config } from "drizzle-kit";

import { env } from "~/env";

export default {
schema: "./src/server/db/schema.ts",
dialect: "sqlite",
driver: "turso",
verbose: true,
dbCredentials: {
url: env.DATABASE_URL,
authToken: env.AUTH_TOKEN,
},
} satisfies Config;
6 replies
DTDrizzle Team
Created by Domski on 1/30/2024 in #help
Best practices for handling planetscale DatabaseErrors with Drizzle?
did you find a way to do this? @Domski
4 replies
DTDrizzle Team
Created by Domski on 1/30/2024 in #help
Best practices for handling planetscale DatabaseErrors with Drizzle?
upvoting this
4 replies
DTDrizzle Team
Created by Liltripple_reid on 10/6/2023 in #help
connection error, fetch failed
And only use the database url for db:push @KG
10 replies
DTDrizzle Team
Created by Liltripple_reid on 10/6/2023 in #help
connection error, fetch failed
The best solution is to use the HOST, USER, PASSWORD method to authenticate with drizzle
10 replies
DTDrizzle Team
Created by Liltripple_reid on 10/6/2023 in #help
connection error, fetch failed
Sorry man haven’t check discord in some days
10 replies
DTDrizzle Team
Created by Liltripple_reid on 10/6/2023 in #help
connection error, fetch failed
Hey yes
10 replies
DTDrizzle Team
Created by Liltripple_reid on 10/23/2023 in #help
planetscale cache error
import { loggerLink } from "@trpc/client";
import { experimental_nextCacheLink as nextCacheLink } from "@trpc/next/app-dir/links/nextCache";
import { experimental_createTRPCNextAppDirServer as createTRPCNextAppDirServer } from "@trpc/next/app-dir/server";
import { cookies } from "next/headers";
import SuperJSON from "superjson";
import { getUserAuth } from "../auth/utils";
import { appRouter } from "../server/routers/_app";

/**
* This client invokes procedures directly on the server without fetching over HTTP.
*/
export const api = createTRPCNextAppDirServer<typeof appRouter>({
config() {
return {
transformer: SuperJSON,
links: [
loggerLink({
enabled: () => true,
}),
nextCacheLink({
revalidate: 1,
router: appRouter,
async createContext() {
const { session } = await getUserAuth();
return {
session,
headers: {
cookie: cookies().toString(),
"x-trpc-source": "rsc-invoke",
},
};
},
}),
],
};
},
});
import { loggerLink } from "@trpc/client";
import { experimental_nextCacheLink as nextCacheLink } from "@trpc/next/app-dir/links/nextCache";
import { experimental_createTRPCNextAppDirServer as createTRPCNextAppDirServer } from "@trpc/next/app-dir/server";
import { cookies } from "next/headers";
import SuperJSON from "superjson";
import { getUserAuth } from "../auth/utils";
import { appRouter } from "../server/routers/_app";

/**
* This client invokes procedures directly on the server without fetching over HTTP.
*/
export const api = createTRPCNextAppDirServer<typeof appRouter>({
config() {
return {
transformer: SuperJSON,
links: [
loggerLink({
enabled: () => true,
}),
nextCacheLink({
revalidate: 1,
router: appRouter,
async createContext() {
const { session } = await getUserAuth();
return {
session,
headers: {
cookie: cookies().toString(),
"x-trpc-source": "rsc-invoke",
},
};
},
}),
],
};
},
});
this is the RSC API generated by kirimase for context if you want to try
8 replies
DTDrizzle Team
Created by Liltripple_reid on 10/23/2023 in #help
planetscale cache error
weird thing is that doing this:
// async function Something
const data = await db.query.table.findMany()
// async function Something
const data = await db.query.table.findMany()
works nicely, but using the trpc helper does not
8 replies
DTDrizzle Team
Created by Liltripple_reid on 10/23/2023 in #help
planetscale cache error
next 13.5.4
8 replies
DTDrizzle Team
Created by Liltripple_reid on 10/23/2023 in #help
planetscale cache error
yea
8 replies
DTDrizzle Team
Created by yoggyd on 9/19/2023 in #help
many to many self reference
ah found the issue, it was about the relationName, thanks a lot!
10 replies
DTDrizzle Team
Created by yoggyd on 9/19/2023 in #help
many to many self reference
@Angelelz these are my relations and tables
export const users = mysqlTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
mode: "date",
fsp: 3,
}).defaultNow(),
image: varchar("image", { length: 255 }),
});

/**
* TODO: Friendships relations needs work
*/
export const usersRelations = relations(users, ({ many }) => ({
secrets: many(secrets),
receiving: many(usersToSecrets),
friendships: many(friendships, { relationName: "followers" }),
}));

export const usersToSecrets = mysqlTable(
"users_to_secrets",
{
userId: varchar("userId", { length: 255 }).notNull(),
secretId: int("secretId").notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.secretId),
})
);

export const usersToSecretsRelations = relations(usersToSecrets, ({ one }) => ({
receiver: one(users, {
fields: [usersToSecrets.userId],
references: [users.id],
}),
secret: one(secrets, {
fields: [usersToSecrets.secretId],
references: [secrets.id],
}),
}));

export const friendships = mysqlTable(
"friendship",
{
userId: varchar("user_id", { length: 255 }).notNull(),
friendId: varchar("friend_id", { length: 255 }).notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.friendId),
})
);

export const friendshipsRelations = relations(friendships, ({ one }) => ({
follower: one(users, {
fields: [friendships.userId],
references: [users.id],
relationName: "follower",
}),
friend: one(users, {
fields: [friendships.friendId],
references: [users.id],
relationName: "friend",
}),
}));
export const users = mysqlTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
mode: "date",
fsp: 3,
}).defaultNow(),
image: varchar("image", { length: 255 }),
});

/**
* TODO: Friendships relations needs work
*/
export const usersRelations = relations(users, ({ many }) => ({
secrets: many(secrets),
receiving: many(usersToSecrets),
friendships: many(friendships, { relationName: "followers" }),
}));

export const usersToSecrets = mysqlTable(
"users_to_secrets",
{
userId: varchar("userId", { length: 255 }).notNull(),
secretId: int("secretId").notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.secretId),
})
);

export const usersToSecretsRelations = relations(usersToSecrets, ({ one }) => ({
receiver: one(users, {
fields: [usersToSecrets.userId],
references: [users.id],
}),
secret: one(secrets, {
fields: [usersToSecrets.secretId],
references: [secrets.id],
}),
}));

export const friendships = mysqlTable(
"friendship",
{
userId: varchar("user_id", { length: 255 }).notNull(),
friendId: varchar("friend_id", { length: 255 }).notNull(),
},
(t) => ({
pk: primaryKey(t.userId, t.friendId),
})
);

export const friendshipsRelations = relations(friendships, ({ one }) => ({
follower: one(users, {
fields: [friendships.userId],
references: [users.id],
relationName: "follower",
}),
friend: one(users, {
fields: [friendships.friendId],
references: [users.id],
relationName: "friend",
}),
}));
not sure if the friendships/followers is conflicting with the other relations
10 replies
DTDrizzle Team
Created by yoggyd on 9/19/2023 in #help
many to many self reference
still having issues 😢, pd: I can't use references because I'm using planetscale
10 replies
DTDrizzle Team
Created by McPizza on 9/7/2023 in #help
Relationships: Self one-one & one-many
my table is something like this I'm trying to work on one-to-many relations for the same table, any idea how to implement it? saw this is still open
// schema

export const users = mysqlTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
mode: "date",
fsp: 3,
}).defaultNow(),
image: varchar("image", { length: 255 }),
});

export const usersRelations = relations(users, ({ many }) => ({
friends: many(users, { relationName: "friends" }), // error here
}));
// schema

export const users = mysqlTable("user", {
id: varchar("id", { length: 255 }).notNull().primaryKey(),
name: varchar("name", { length: 255 }),
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
mode: "date",
fsp: 3,
}).defaultNow(),
image: varchar("image", { length: 255 }),
});

export const usersRelations = relations(users, ({ many }) => ({
friends: many(users, { relationName: "friends" }), // error here
}));
throws errors
9 replies
DTDrizzle Team
Created by McPizza on 9/7/2023 in #help
Relationships: Self one-one & one-many
@McPizza can you show the table & relations you used to make it work? I'm struggling trying to setup something similar
9 replies
DTDrizzle Team
Created by son dang on 7/19/2023 in #help
Self referencing
what if I just need the children relation? it throws errors
3 replies