templates 中範本庫裡的每個範本一個文件。範本的檔案(專案 zip 與 PDF)不在這裡:它們保存在 filestore 的 template/<_id>/v/<version>/ 之下。此集合屬於 web 模組 template-gallery(services/web/modules/template-gallery)。schema 是 services/web/modules/template-gallery/app/src/models/Template.mjs 中的 Mongoose 模型 Template;邏輯位於 services/web/modules/template-gallery/app/src/TemplateGalleryManager.mjs 以及同目錄下的 TemplateGalleryHelper.mjs。
欄位
寫入方
只有網站管理員與
OVERLEAF_TEMPLATES_USER_ID 中的使用者可以呼叫這三個路由(services/web/modules/template-gallery/app/src/Router.mjs:55-62,70-84, PermissionsMiddleware.mjs:8-19)。
讀取方
索引
Mongoose 的
autoIndex 已關閉(services/web/app/src/infrastructure/Mongoose.mjs:7)。tools/migrations/20190912145030_create_templates_indexes.mjs(唯一的 project_id、user_id、name)標記為 server-pro 與 saas,因此不會在 CE 中執行,CE 只執行 server-ce 遷移(server-ce/init_scripts/900_run_web_migrations.sh)。
備註
- 上游把
templates視為過時的集合,並在自己的網站上刪除它(tools/migrations/20241002180623_drop_unused_collections.mjs,標記為saas)。在 Ayakaleaf Pro 中,範本庫模組會使用它。 - 依名稱排序使用不區分大小寫的定序,
TemplateGalleryManager.mjs:186-188處的註解指出name索引也需要相同的定序。CE 沒有name索引,因此 Mongo 在記憶體中排序。 - 刪除來源專案或擁有者不會刪除範本。

