'tonyyprints'
'tonyyprints'
Explore posts from servers
DTDrizzle Team
Created by 'tonyyprints' on 6/12/2024 in #help
Migrations taking the first snapshot
No description
2 replies
DTDrizzle Team
Created by 'tonyyprints' on 3/24/2024 in #help
bigint is not a number
I'm trying to execute this query but get the following error that I'm hoping someone here can help me with:
const profilePhoto = await ctx.db.query.profile.findFirst({
where: eq(schema.profile.id, profile.profileId),
columns: {
profilePhotoId: true,
},
})
const profilePhoto = await ctx.db.query.profile.findFirst({
where: eq(schema.profile.id, profile.profileId),
columns: {
profilePhotoId: true,
},
})
but get the following overload error:
Argument of type bigint is not assignable to parameter of type number | SQLWrapper.
Argument of type bigint is not assignable to parameter of type number | SQLWrapper.
My schema for the related fields are also posted below.
export const profile = mySqlTable("Profile", {
id: serial("id").primaryKey(),
userName: varchar("userName", { length: 255 }).unique().notNull(),
bio: text("bio"),
profilePhotoId: bigint("profilePhoto", {mode: "bigint", unsigned: true}).references(() => profilePhoto.id),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
});

export const profileRelations = relations(profile, ({ one, many }) => ({
profilePhoto: one(profilePhoto, {
fields: [profile.profilePhotoId],
references: [profilePhoto.id],
}),
posts: many(post),
}));

export const profilePhoto = mySqlTable("ProfilePhoto", {
id: serial("id").primaryKey().notNull(),
url: varchar("url", { length: 255 }).notNull(),
// key: varchar("varchar", { length: 255 }).notNull(),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
});

export const profilePhotoRelations = relations(profilePhoto, ({ one }) => ({
profile: one(profile, {
fields: [profilePhoto.id],
references: [profile.id],
}),
}));
export const profile = mySqlTable("Profile", {
id: serial("id").primaryKey(),
userName: varchar("userName", { length: 255 }).unique().notNull(),
bio: text("bio"),
profilePhotoId: bigint("profilePhoto", {mode: "bigint", unsigned: true}).references(() => profilePhoto.id),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
});

export const profileRelations = relations(profile, ({ one, many }) => ({
profilePhoto: one(profilePhoto, {
fields: [profile.profilePhotoId],
references: [profilePhoto.id],
}),
posts: many(post),
}));

export const profilePhoto = mySqlTable("ProfilePhoto", {
id: serial("id").primaryKey().notNull(),
url: varchar("url", { length: 255 }).notNull(),
// key: varchar("varchar", { length: 255 }).notNull(),
createdAt: timestamp("createdAt")
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt").onUpdateNow(),
});

export const profilePhotoRelations = relations(profilePhoto, ({ one }) => ({
profile: one(profile, {
fields: [profilePhoto.id],
references: [profile.id],
}),
}));
7 replies