edarcode
edarcode
Explore posts from servers
DTDrizzle Team
Created by edarcode on 10/17/2024 in #help
turso
No description
6 replies
DTDrizzle Team
Created by edarcode on 10/14/2024 in #help
transations
No description
23 replies
DTDrizzle Team
Created by edarcode on 8/17/2024 in #help
query with
// schema
export const usersTable = sqliteTable("users", {
id: text("id").primaryKey(),
username: text("username"),
// otros campos...
});

export const followsTable = sqliteTable(
"follows",
{
followerId: text("follower_id").references(() => usersTable.id),
followingId: text("following_id").references(() => usersTable.id),
createdAt: text("created_at").default(sql`(CURRENT_TIMESTAMP)`),
},
(followsTable) => ({
id: primaryKey([followsTable.followerId, followsTable.followingId]),
})
);
// schema
export const usersTable = sqliteTable("users", {
id: text("id").primaryKey(),
username: text("username"),
// otros campos...
});

export const followsTable = sqliteTable(
"follows",
{
followerId: text("follower_id").references(() => usersTable.id),
followingId: text("following_id").references(() => usersTable.id),
createdAt: text("created_at").default(sql`(CURRENT_TIMESTAMP)`),
},
(followsTable) => ({
id: primaryKey([followsTable.followerId, followsTable.followingId]),
})
);
I'm trying to do this query, but "with" doesn't recommend anything, did I link my schema wrong?
import { db } from "../../../db/db";
import { EdarErr } from "../../../error/EdarErr";
import { Uuid } from "../../../types";

export const getAccountService = async (id: Uuid) => {
const account = await db.query.usersTable.findFirst({
where: (user, { eq }) => eq(user.id, id),
with: { ?: true },
});

if (!account) throw new EdarErr(404, "Account not found");

return account;
};
import { db } from "../../../db/db";
import { EdarErr } from "../../../error/EdarErr";
import { Uuid } from "../../../types";

export const getAccountService = async (id: Uuid) => {
const account = await db.query.usersTable.findFirst({
where: (user, { eq }) => eq(user.id, id),
with: { ?: true },
});

if (!account) throw new EdarErr(404, "Account not found");

return account;
};
10 replies
DTDrizzle Team
Created by edarcode on 8/16/2024 in #help
seed
No description
15 replies