feat: add createdAt to userKeys, tour participations

This commit is contained in:
MTG2000
2022-09-09 07:50:36 +03:00
parent f7d86633b3
commit 764c6b6622
3 changed files with 20 additions and 5 deletions

View File

@@ -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')
}
})

View File

@@ -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;

View File

@@ -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