> For the complete documentation index, see [llms.txt](https://docs.ohmyapp.io/main/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ohmyapp.io/main/guide/faq/logic/9.md).

# 9. 순서대로 번호를 부여하고 싶어요.

리뷰 글에서 유저가 몇번째 리뷰를 쓴 건지 표현하고 싶을 때가 있어요.

여기서는 특정 유저가 작성한 글을 찾고 카운팅을 해볼게요.

커뮤니티 메타에 예시로 **'n번째 리뷰'(reviewCount)**&#xB77C;는 항목을 만들어 줬어요.

<figure><img src="/files/wgb6YE2TMi6daNNX92bd" alt=""><figcaption></figcaption></figure>

이제 로직 설정으로 들어가 새 로직을 생성할게요.

<div align="left"><figure><img src="/files/oFNPATpA5CHa8yfb0Aft" alt="" width="375"><figcaption></figcaption></figure></div>

먼저 작성된 리뷰 글이 최초의 글인지 아닌지를 판단해요.

판단을 위해 **@query**로 글을 쓴 유저가 커뮤니티에 쓴 글이 있는지 없는지 검색해요.

이때 정렬 항목을 **\_createTime**을 내림차순으로 설정해 최신 순서대로 글을 가져와요.

<figure><img src="/files/GnRflectTBGrUN58PaN3" alt=""><figcaption></figcaption></figure>

가져온 데이터 중 첫번째를 **userReview**에 저장(**@setValue**)해요.

<figure><img src="/files/2yu80amtgEWjZIdlOgPH" alt=""><figcaption></figcaption></figure>

가져온 데이터가 빈 값이면 첫 글이기에 숫자 1을 부여하고, 데이터가 있다면 유저가 최근에 썼던 글의 번호를 가져와서 1을 올릴게요.

**#ifTrue**에 꼭 **Number** 형태로 바꿔주세요.

<figure><img src="/files/Es9ji1qqK7wnoB92CVSM" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/HiY4IYpg3LjMRAbgU3uB" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/KNG0z0ihzRznK0QOaYTy" alt=""><figcaption></figcaption></figure>

이제 결과값인 **setCount**를 새로 작성된 글의 **n번째 리뷰** 항목에 넣어줄게요.

<div align="left"><figure><img src="/files/o7tTcqHKAg5vhtwk0Bw8" alt="" width="375"><figcaption></figcaption></figure></div>

25.01.13 Jihwan


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.ohmyapp.io/main/guide/faq/logic/9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
