# 게시글 조회수 기능

### Vercel CLI 설치하기

Vercel PostgreSQL과 연결하기 위해 Vercel CLI를 사용합니다. 아래의 명령어로 Vercel CLI를 설치해주세요. 설치에 문제가 있다면 [공식 문서](https://vercel.com/docs/cli#installing-vercel-cli)를 확인해주세요.

```bash
pnpm i -g vercel
```

### AI와 함께 쿼리 작성하기

ChatGPT, Claude 등 AI를 활용하면 쉽게 SQL 구문을 완성할 수 있습니다. 강의에서 사용한 프롬프트를 활용해서 자신만의 쿼리를 작성해보세요.

{% code title="테이블 생성 쿼리 프롬프트" %}

```
PostgreSQL을 사용하는 쿼리문을 작성하는 데 도움을 줘.

우선은 테이블을 생성하는 쿼리가 필요해. 
그 테이블은 views라는 이름을 가진 테이블이야. 
테이블에는 slug, count라는 칼럼이 존재해야 해.
```

{% endcode %}

{% code title="조회수 증가 쿼리 프롬프트" %}

```
다음은 views 테이블에 업데이트하는 쿼리를 작성해줘. 

slug를 기준으로 열을 찾고 count를 1 증가시키는 쿼리야. 
만약에 slug가 존재하지 않으면 insert하고 count를 1로 지정해야 해. 
이미 slug있다면 count 1을 증가시키는 쿼리를 작성해줘.
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://book.hajoeun.dev/friendly-next-js/part-3-next.js/undefined-4/undefined-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
