Migrations!
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "User" ADD COLUMN "createdAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
ADD COLUMN "updatedAt" TIMESTAMP(3);
|
||||||
@@ -11,8 +11,10 @@ datasource db {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model User {
|
model User {
|
||||||
id String @id @default(uuid())
|
id String @id @default(uuid())
|
||||||
email String @unique
|
email String @unique
|
||||||
password String?
|
password String?
|
||||||
time_joined Int?
|
time_joined Int?
|
||||||
|
createdAt DateTime? @default(now())
|
||||||
|
updatedAt DateTime? @updatedAt
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ export class User {
|
|||||||
email: string;
|
email: string;
|
||||||
password?: Nullable<string>;
|
password?: Nullable<string>;
|
||||||
time_joined?: Nullable<number>;
|
time_joined?: Nullable<number>;
|
||||||
|
createdAt?: Nullable<DateTime>;
|
||||||
|
updatedAt?: Nullable<DateTime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export abstract class IQuery {
|
export abstract class IQuery {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { PrismaService } from 'prisma/prisma.service';
|
|||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: [process.env.WEBAPP_URL],
|
origin: [process.env.WEBAPP_URL, 'https://studio.apollographql.com'],
|
||||||
allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
|
allowedHeaders: ['content-type', ...supertokens.getAllCORSHeaders()],
|
||||||
credentials: true,
|
credentials: true,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ type User {
|
|||||||
email: String!
|
email: String!
|
||||||
password: String
|
password: String
|
||||||
time_joined: Int,
|
time_joined: Int,
|
||||||
|
createdAt: DateTime
|
||||||
|
updatedAt: DateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
input CreateUserInput {
|
input CreateUserInput {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export class UsersResolver {
|
|||||||
return this.usersService.create(createUserInput);
|
return this.usersService.create(createUserInput);
|
||||||
}
|
}
|
||||||
@Query('users')
|
@Query('users')
|
||||||
findAll(@Args('params') params: Prisma.UserFindManyArgs) {
|
findAll(@Args('params') params?: Prisma.UserFindManyArgs) {
|
||||||
return this.usersService.users(params);
|
return this.usersService.users(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export class UsersService {
|
|||||||
return await this.prismaService.user.findUnique({ where: uniqueInput });
|
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);
|
return await this.prismaService.user.findMany(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user