# 23. 리뷰 평점을 계산하고 싶어요.

{% hint style="info" %}
고급자를 위한 가이드에요.

메타, 항목 id, 데이터 구조의 이해가 잡히신 분들께 추천드려요.
{% endhint %}

리뷰 평점을 계산하는 것처럼 특정 문서들을 계산해야 할 때가 있어요.

계산하는 방법은 서비스, 앱 구조, 화면에 따라 정말 다양하니 현 상황에 알맞은 방법을 잘 골라야 해요.

여기서는 그중 1가지 방법을 소개 드릴게요.

```json
"collectionOptions": {
		"joinSummaries": [
			{
				"id": "reviewInfo", // id 정의
				"items": [
					{
						"id": "avg",
						"targetItem": "rating", // 평균을 구할 항목
						"type": "#avg" // 평균을 구하는 메서드
					},
					{
						"id": "size",
						"type": "#size" // 총 개수를 구하는 메서드
					}
				],
				"joinMeta": "pkg_categoryMap_review", // 참조할 메타
				"joinOptions": {
					"as": {
						"joinMetaName": "restaurantReview", // 참조할 메타 정의
						"metaName": "restaurant" // 현재 메타 정의
					},
					"filters": [
						{
							"#eq": {
								"#left": "restaurant._id", // 현재 메타의 _id
								"#right": "restaurantReview.storeJoin._id" // 참조 메타의 storeJoin._id
							}
						}
					]
				}
			}
		]
	}
```

**reviewInfo.avg** : 평균

**reviewInfo. size**: 리뷰 개수

위 코드를 복사해서 사용할 메타의 documentMeta 안에 붙여 넣어 주세요.

메타 코드를 보는 법은 이 [가이드](/main/guide/dictionary/collection-name.md)를 참고해 주세요.

<div align="left"><figure><img src="/files/7HXFQYE0HoeltR6QG8vg" alt="" width="334"><figcaption></figcaption></figure></div>

24.08.02 Jihwan


---

# 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://docs.ohmyapp.io/main/guide/faq/app-settings/23.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.
