> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Contacts 컬렉션

`contacts` 는 공유 대화 상자가 추천할 수 있도록 사용자가 어떤 사용자와 함께 작업했는지 기억합니다. 사용자당 문서 하나입니다. `web`이 소유하며 Mongoose 스키마는 없습니다. 코드는 `services/web/app/src/Features/Contacts/ContactManager.mjs`입니다.

#### 필드

| 필드 | 타입 | 의미 | 출처 |
| - | - | - | - |
| `_id` | ObjectId | 문서 id로, upsert가 생성합니다. | `ContactManager.mjs:5-12` |
| `user_id` | ObjectId | 이 연락처의 주인인 사용자. 사용자당 문서 하나입니다. | `ContactManager.mjs:6` |
| `contacts` | Object | 연락처의 사용자 id(문자열)를 키로 하는 맵. | `ContactManager.mjs:8-9` |
| `contacts.<userId>.n` | Number | 두 사용자가 연결된 횟수. | `ContactManager.mjs:8` |
| `contacts.<userId>.ts` | Date | 마지막으로 연결된 시각. | `ContactManager.mjs:9` |

#### 쓰는 코드

| 코드 | 하는 일 |
| - | - |
| `ContactManager.mjs:4-13` (`touchContact`), `:23-28` (`addContact`) | 두 사용자의 문서를 모두 upsert합니다: `n`에 `$inc`, `ts`에 `$set`. |
| `services/web/app/src/Features/Collaborators/CollaboratorsHandler.mjs:155-157` | `addUserIdToProject`는 추가한 사용자가 주어지면 `addContact`를 호출합니다. 초대 수락(초대한 사람과 초대받은 사람, `services/web/app/src/Features/Collaborators/CollaboratorsInviteHandler.mjs:199-205`)과 소유권 이전(새 소유자와 이전 소유자, `services/web/app/src/Features/Collaborators/OwnershipTransferHandler.mjs:138-144`)이 이에 해당합니다. 공유 링크로 참여하면 추가한 사용자가 전달되지 않으므로(`services/web/app/src/Features/TokenAccess/TokenAccessController.mjs:386-388`, `:632-634`) 연락처가 추가되지 않습니다. |

#### 읽는 코드

| 코드 | 하는 일 |
| - | - |
| `ContactManager.mjs:15-21`, `:30-42` | `getContactIds`: `n`, 그다음 `ts` 순으로, 둘 다 큰 값부터 정렬합니다. |
| `services/web/app/src/Features/Contacts/ContactController.mjs:19-59` | `GET /user/contacts` (`services/web/app/src/Features/Contacts/ContactRouter.mjs:22-26`): 상위 50명을 사용자로 반환하며(임시 계정 제외), 모듈이 `getContacts` 훅으로 추가하는 항목도 포함합니다. |

#### 인덱스

| 이름 | 키 | 옵션 | 마이그레이션 |
| - | - | - | - |
| `user_id_1` | `{ user_id: 1 }` | unique | `tools/migrations/20190912145001_create_contacts_indexes.mjs` |

#### 참고

* 연락처는 양방향입니다. B를 A의 프로젝트에 추가하면 B는 A의 연락처가 되고 A도 B의 연락처가 됩니다.
* 연락처나 문서를 제거하는 것은 없으며, 사용자가 삭제되어도 남습니다.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.