Inflearn brand logo image

Inflearn Community Q&A

gspark06266890's profile image
gspark06266890

asked

Node and React series that you can learn by following - Creating a Reddit site (NextJS) (Pages Router)

typeorm datasource 질문

Written on

·

333

0

typeorm datasource를 설정하는 부분에서 database 이름을 설정하는 부분이 있는데 이 부분을 강의에서는 postgres를 되어 있는데 이 postgres라는 데이터베이스 이름은 어디서 설정이 된건가요?

typescriptnodejspostgresqlreactdockerNext.js클론코딩

Answer 1

0

johnahn님의 프로필 이미지
johnahn
Instructor

안녕하세요 건상님!

postgres 이름으로 넣으면 데이터베이스의 이름이 postgres로 생성되는 것입니다!
다른 부분에서 생성하는 것이 아닌 datasource 설정하는 부분에서 데이테베이스를 실제 생성하는 것입니다 ^^
그래서 여기에서 최초 설정해주는 부분이라고 보시면 됩니다.
감사합니다.

gspark06266890님의 프로필 이미지
gspark06266890
Questioner

그러면 기존의 데이터베이스가 아니 새로운 데이터베이스를 생성하고 싶을때는 어떻게 생성하면 될까요?

johnahn님의 프로필 이미지
johnahn
Instructor

만약 다른 이름의 아직 생성되지 않은 데이터베이스를 생성하고 싶으시면 다른 이름을 넣어주시면 됩니다
감사합니다.

gspark06266890님의 프로필 이미지
gspark06266890
Questioner

datasource 부분의 datebase에 reddit을 작성하고 server를 실행했더니 초기화 하는 부분에서 error: database "reddit" does not exist라는 에러가 뜨는데 혹시 다른 부분에 이름을 넣어줘야하나요?

 

export const AppDataSource = new DataSource({
    type: "postgres",
    host: "localhost",
    port: 5432,
    username: "test",
    password: "test",
    database: "reddit",
    synchronize: true,
    logging: false,
    entities: ["src/entity/**/*.ts"],
    migrations: [],
    subscribers: [],
})
gspark06266890's profile image
gspark06266890

asked

Ask a question