added tons of features
This commit is contained in:
17
data/accout.ts
Normal file
17
data/accout.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import {db} from '@/lib/db/prisma/client'
|
||||
import {redisClient} from '@/lib/db/redis/client'
|
||||
import {toInt} from '@/lib/utils'
|
||||
|
||||
export const getAccountByUserId = async (userId: unknown) => {
|
||||
userId = toInt(userId)
|
||||
if (!userId) return null
|
||||
|
||||
try {
|
||||
return await db.account.findFirst({
|
||||
where: {userId}
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
21
data/user.ts
Normal file
21
data/user.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import {db} from '@/lib/db/prisma/client'
|
||||
import {toInt} from '@/lib/utils'
|
||||
|
||||
export const getUsers = async () => await db.user.findMany()
|
||||
|
||||
export const getAllUsers = await db.user.findMany()
|
||||
export const getUserById = async (id: unknown) => {
|
||||
id = toInt(id)
|
||||
if (!id) return null
|
||||
|
||||
try {
|
||||
return await db.user.findUnique({
|
||||
where: {
|
||||
id: parseInt(id as string)
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user