Migrations!

This commit is contained in:
2022-09-08 21:43:50 +02:00
parent 2a70074382
commit fb0ca6a3ba
7 changed files with 14 additions and 5 deletions

View File

@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "updatedAt" TIMESTAMP(3);

View File

@@ -15,4 +15,6 @@ model User {
email String @unique
password String?
time_joined Int?
createdAt DateTime? @default(now())
updatedAt DateTime? @updatedAt
}

View File

@@ -18,6 +18,8 @@ export class User {
email: string;
password?: Nullable<string>;
time_joined?: Nullable<number>;
createdAt?: Nullable<DateTime>;
updatedAt?: Nullable<DateTime>;
}
export abstract class IQuery {

View File

@@ -7,7 +7,7 @@ import { PrismaService } from 'prisma/prisma.service';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: [process.env.WEBAPP_URL],
origin: [process.env.WEBAPP_URL, 'https://studio.apollographql.com'],
allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
credentials: true,
});

View File

@@ -5,6 +5,8 @@ type User {
email: String!
password: String
time_joined: Int,
createdAt: DateTime
updatedAt: DateTime
}
input CreateUserInput {

View File

@@ -11,7 +11,7 @@ export class UsersResolver {
return this.usersService.create(createUserInput);
}
@Query('users')
findAll(@Args('params') params: Prisma.UserFindManyArgs) {
findAll(@Args('params') params?: Prisma.UserFindManyArgs) {
return this.usersService.users(params);
}

View File

@@ -10,7 +10,7 @@ export class UsersService {
return await this.prismaService.user.findUnique({ where: uniqueInput });
}
async users(params: Prisma.UserFindManyArgs) {
async users(params?: Prisma.UserFindManyArgs) {
return await this.prismaService.user.findMany(params);
}