26 lines
586 B
TypeScript
26 lines
586 B
TypeScript
"use server"
|
|
|
|
import { db } from "@/app/server/db"
|
|
import { redPackets } from "@/app/server/schema/red-packet"
|
|
import { eq } from "drizzle-orm"
|
|
|
|
export async function getRedPacketByPublicId(id: string) {
|
|
const rows = await db
|
|
.select()
|
|
.from(redPackets)
|
|
.where(eq(redPackets.publicId, id))
|
|
.limit(1)
|
|
|
|
return rows[0] ?? null
|
|
}
|
|
|
|
export async function getRedPacketByAdminId(id: string) {
|
|
const rows = await db
|
|
.select()
|
|
.from(redPackets)
|
|
.where(eq(redPackets.adminId, id))
|
|
.limit(1)
|
|
|
|
return rows[0] ?? null
|
|
}
|