> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # Storage Mastra 會透過 `src/mastra/` 正下方的 `storage.ts` 檔案設定專案的預設 [Storage](https://mastra.zisheng.pro/zh-TW/docs/storage/overview)。此檔案會 default export 一個 store,取代 Memory、Workflow、Observability 與其他 Storage domain 所使用的內建記憶體內 store。 本頁說明檔案式慣例。若要了解後端選擇、Storage domain、保留政策與 Provider 詳細資訊,請參閱 [Storage 概觀](https://mastra.zisheng.pro/zh-TW/docs/storage/overview)。 ## 快速開始 使用 [`LibSQLStore`](https://mastra.zisheng.pro/zh-TW/reference/storage/libsql) 建立以本機檔案為基礎的 store: ```typescript import { LibSQLStore } from '@mastra/libsql' export default new LibSQLStore({ id: 'mastra-storage', url: 'file:./mastra.db', }) ``` Mastra 會先註冊此 store,再註冊檔案式 Agent 與 Workflow,因此依賴 Storage 的 primitive 會繫結至此 store,而不是預設的記憶體內 store。 ## 正式環境後端 `storage.ts` 可以 export 任何 Mastra Storage adapter,例如 LibSQL、PostgreSQL 或 MongoDB。若要了解設定模式、Provider 支援情況與 schema 詳細資訊,請參閱 [Storage 概觀](https://mastra.zisheng.pro/zh-TW/docs/storage/overview)、[Observability signal 支援情況](https://mastra.zisheng.pro/zh-TW/docs/observability/overview)與 [Storage 參考文件](https://mastra.zisheng.pro/zh-TW/reference/storage/overview)。 ## 與程式碼設定的優先順序 以程式碼註冊的 Storage 優先於 `storage.ts`。當整個專案使用一個 store 即可時,請使用 `storage.ts`;若設定取決於 `src/mastra/index.ts` 中的執行階段接線,請改用程式碼註冊。