mirror of
https://github.com/aljazceru/landscape-template.git
synced 2026-02-11 09:34:24 +01:00
feat: add createdAt to userKeys, tour participations
This commit is contained in:
@@ -171,9 +171,16 @@ const MyProfile = objectType({
|
||||
|
||||
t.nonNull.list.nonNull.field('walletsKeys', {
|
||||
type: "WalletKey",
|
||||
resolve: async (parent, _, context) => {
|
||||
const userKeys = await prisma.user.findUnique({ where: { id: parent.id } }).userKeys();
|
||||
return userKeys.map(k => ({ ...k, is_current: k.key === context.userPubKey }))
|
||||
resolve: (parent, _, context) => {
|
||||
return prisma.userKey.findMany({
|
||||
where: {
|
||||
user_id: parent.id,
|
||||
},
|
||||
orderBy: {
|
||||
createdAt: "asc"
|
||||
}
|
||||
})
|
||||
.then(keys => keys.map(k => ({ ...k, is_current: k.key === context.userPubKey })))
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -283,6 +290,7 @@ const WalletKey = objectType({
|
||||
definition(t) {
|
||||
t.nonNull.string('key');
|
||||
t.nonNull.string('name');
|
||||
t.nonNull.date('createdAt');
|
||||
t.nonNull.boolean('is_current')
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "TournamentParticipant" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "UserKey" ADD COLUMN "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
@@ -72,8 +72,9 @@ model User {
|
||||
}
|
||||
|
||||
model UserKey {
|
||||
key String @id
|
||||
name String @default("My new wallet key")
|
||||
key String @id
|
||||
name String @default("My new wallet key")
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User? @relation(fields: [user_id], references: [id])
|
||||
user_id Int?
|
||||
@@ -349,6 +350,7 @@ model TournamentParticipant {
|
||||
tournament_id Int
|
||||
user User @relation(fields: [user_id], references: [id])
|
||||
user_id Int
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
email String
|
||||
hacking_status Int
|
||||
|
||||
Reference in New Issue
Block a user