> ## 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.

# Spelling Preferences コレクション

`spellingPreferences` は各ユーザーの辞書、つまりエディターのスペルチェックで "Add to dictionary" から追加した単語を保持します。ユーザーごとに 1 つのドキュメントです。`web` が管理しており、Mongoose スキーマはありません。コードは `services/web/app/src/Features/Spelling/LearnedWordsManager.mjs` です。

#### フィールド

| フィールド | 型 | 意味 | 出典 |
| - | - | - | - |
| `_id` | ObjectId | ドキュメント id。upsert によって作成されます。 | `LearnedWordsManager.mjs:21-31` |
| `token` | String | ユーザーの id。名前とは裏腹に、スペル関連のルートはログイン中のユーザーの id（`SessionManager.getLoggedInUserId`）を渡します。 | `LearnedWordsManager.mjs:23` |
| `learnedWords` | Array of String | ユーザーが追加した単語。 | `LearnedWordsManager.mjs:26` |

#### 書き込むコード

| コード | 動作 |
| - | - |
| `LearnedWordsManager.mjs:13-32` (`learnWord`) | `POST /spelling/learn` (`services/web/app/src/router.mjs:1037-1041`, `services/web/app/src/Features/Spelling/SpellingController.mjs:45-58`): 単語を upsert 付きで `$addToSet` します。リストが `Settings.maxDictionarySize` バイトを超える場合は拒否します。 |
| `LearnedWordsManager.mjs:38-47` (`unlearnWord`) | `POST /spelling/unlearn` (`router.mjs:1043-1047`, `SpellingController.mjs:66-79`): 単語を `$pull` します。 |
| `LearnedWordsManager.mjs:84-86` (`deleteUsersLearnedWords`) | ドキュメントを削除します。唯一のラッパーである `SpellingHandler.deleteUserDictionary`（`services/web/app/src/Features/Spelling/SpellingHandler.mjs:24-26`）は、web とそのモジュールのどこからも呼ばれていません。 |

#### 読み取るコード

| コード | 動作 |
| - | - |
| `LearnedWordsManager.mjs:52-67` (`getLearnedWords`) | 重複を除いた単語を返します。 |
| `services/web/app/src/Features/Project/ProjectController.mjs:671` | プロジェクトを開いたときに辞書をエディターへ送ります（`SpellingHandler.getUserDictionary`）。 |

#### インデックス

| 名前 | キー | オプション | マイグレーション |
| - | - | - | - |
| `token` | `{ token: 1 }` | | `tools/migrations/20190912145027_create_spellingPreferences_indexes.mjs` |

#### 補足

* インデックスは一意ではありません。`token` に対する upsert により、ユーザーごとに 1 つのドキュメントが保たれます。
* ユーザーを削除しても、このドキュメントは削除されません。


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