This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { TaskModule } from './modules/task/task.module'; | |
import { UserModule } from './modules/user/user.module'; | |
@Module({ | |
imports: [TaskModule, UserModule], | |
}) | |
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { TaskService } from './task.service'; | |
import { TaskController } from './task.controller'; | |
@Module({ | |
controllers: [TaskController], | |
providers: [TaskService], | |
}) | |
export class TaskModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Get, Post } from '@nestjs/common'; | |
@Controller('task') | |
export class TaskController { | |
@Post() | |
createTask(): string { | |
return 'This action adds a new task'; | |
} | |
@Get() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Controller, Get, Post } from '@nestjs/common'; | |
import { TaskService } from './task.service'; | |
import { Task } from './models/task.entity'; | |
@Controller('task') | |
export class TaskController { | |
constructor(private taskService: TaskService) {} | |
@Post() | |
createTask(@Body() task: Task): void { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@nestjs/common'; | |
import { Task } from './models/task.entity'; | |
@Injectable() | |
export class TaskService { | |
private readonly tasks: Task[] = []; | |
createTask(task: Task): void { | |
this.tasks.push(task); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generator client { | |
provider = "prisma-client-js" | |
previewFeatures = ["transactionApi"] | |
} | |
datasource db { | |
provider = "postgresql" | |
url = env("DATABASE_URL") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Environment variables declared in this file are automatically made available to Prisma. | |
# See the documentation for more detail: https://pris.ly/d/prisma-schema#using-environment-variables | |
# Prisma supports the native connection string format for PostgreSQL, MySQL and SQLite. | |
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings | |
DATABASE_URL="postgresql://admin:password@localhost:5432/admin?schema=public" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createCompany = async (prisma: PrismaClient) => { | |
await prisma.company.create({ | |
data: { | |
name: 'Acme', | |
}, | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Company create | |
*/ | |
export type CompanyCreateArgs = { | |
/** | |
* Select specific fields to fetch from the Company | |
**/ | |
select?: CompanySelect | null | |
/** | |
* Choose, which related nodes to fetch as well. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createProduct = async (prisma: PrismaClient) => { | |
await prisma.product.create({ | |
data: { | |
name: 'Dynamite', | |
description: 'It goes "boom"', | |
company: { | |
connect: { | |
name: 'Acme', | |
}, | |
}, |
OlderNewer