Skip to content

Commit

Permalink
new storage stuff (#1727)
Browse files Browse the repository at this point in the history
  • Loading branch information
calcsam authored and abhiaiyer91 committed Feb 6, 2025
1 parent cd00f15 commit f2c9d75
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 287 deletions.
4 changes: 3 additions & 1 deletion docs/src/pages/docs/reference/storage/_meta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const meta = {
"mastra-storage": "Mastra Storage",
libsql: "LibSQL Storage",
postgresql: "PostgreSQL Storage",
upstash: "Upstash Storage",
};

export default meta;
69 changes: 69 additions & 0 deletions docs/src/pages/docs/reference/storage/libsql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
title: "LibSQL Storage | Storage System | Mastra Core"
description: Documentation for the LibSQL storage implementation in Mastra.
---

# LibSQL Storage

The LibSQL storage implementation provides a SQLite-compatible storage solution that can run both in-memory and as a persistent database.

## Installation

```bash
npm install @mastra/storage-libsql
```

## Usage

```typescript copy showLineNumbers
import { LibSQLStorage } from "@mastra/storage-libsql";

// In-memory database (development)
const storage = new LibSQLStorage({
url: "file::memory:?cache=shared"
});

// Persistent database (production)
const storage = new LibSQLStorage({
url: process.env.DATABASE_URL
});
```

## Parameters

<PropertiesTable
content={[
{
name: "url",
type: "string",
description: "Database URL. Use 'file::memory:?cache=shared' for in-memory database or a LibSQL-compatible connection string for persistent storage.",
isOptional: false,
},
{
name: "authToken",
type: "string",
description: "Authentication token for remote LibSQL databases.",
isOptional: true,
}
]}
/>

## Additional Notes

### In-Memory vs Persistent Storage

The in-memory configuration (`file::memory:?cache=shared`) is useful for:
- Development and testing
- Temporary storage that doesn't need to persist
- Quick prototyping

For production use cases, use a persistent database URL:
- Local file: `file:local.db`
- Remote LibSQL: `libsql://your-database.turso.io`

### Schema Management

The storage implementation handles schema creation and updates automatically. It creates the following tables:
- `threads`: Stores conversation threads
- `messages`: Stores individual messages
- `metadata`: Stores additional metadata for threads and messages
286 changes: 0 additions & 286 deletions docs/src/pages/docs/reference/storage/mastra-storage.mdx

This file was deleted.

Loading

0 comments on commit f2c9d75

Please sign in to comment.