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

`spellingPreferences` holds each user's dictionary: the words the user added through "Add to dictionary" in the editor's spell check. One document per user. `web` owns it, without a Mongoose schema; the code is `services/web/app/src/Features/Spelling/LearnedWordsManager.mjs`.

#### Fields

| Field | Type | Meaning | Source |
| - | - | - | - |
| `_id` | ObjectId | Document id, created by the upsert. | `LearnedWordsManager.mjs:21-31` |
| `token` | String | The user's id. The spelling routes pass the id of the logged-in user (`SessionManager.getLoggedInUserId`), despite the name. | `LearnedWordsManager.mjs:23` |
| `learnedWords` | Array of String | The words the user added. | `LearnedWordsManager.mjs:26` |

#### Who Writes It

| Code | What it does |
| - | - |
| `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`): `$addToSet` the word, with upsert. Refuses when the list would grow past `Settings.maxDictionarySize` bytes. |
| `LearnedWordsManager.mjs:38-47` (`unlearnWord`) | `POST /spelling/unlearn` (`router.mjs:1043-1047`, `SpellingController.mjs:66-79`): `$pull` the word. |
| `LearnedWordsManager.mjs:84-86` (`deleteUsersLearnedWords`) | Deletes the document. Its only wrapper, `SpellingHandler.deleteUserDictionary` (`services/web/app/src/Features/Spelling/SpellingHandler.mjs:24-26`), has no caller in web or its modules. |

#### Who Reads It

| Code | What it does |
| - | - |
| `LearnedWordsManager.mjs:52-67` (`getLearnedWords`) | Returns the words without duplicates. |
| `services/web/app/src/Features/Project/ProjectController.mjs:671` | Sends the dictionary to the editor when a project opens (`SpellingHandler.getUserDictionary`). |

#### Indexes

| Name | Keys | Options | Migration |
| - | - | - | - |
| `token` | `{ token: 1 }` | | `tools/migrations/20190912145027_create_spellingPreferences_indexes.mjs` |

#### Notes

* The index is not unique; the upsert on `token` keeps one document per user.
* Deleting a user does not delete this document.


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