Storage Adapters
MemoryStorageAdapter
In-memory storage adapter for testing.
Constructor
typescript
new MemoryStorageAdapter()Example:
typescript
import { MemoryStorageAdapter } from '@bucket-db/core';
const adapter = new MemoryStorageAdapter();Additional Methods
clear(): void
Clear all stored data (testing utility).
FileSystemAdapter
Local file system storage adapter.
Constructor
typescript
new FileSystemAdapter(config: FileSystemAdapterConfig)Parameters:
config.basePath- Base directory path for storage
Example:
typescript
import { FileSystemAdapter } from '@bucket-db/core';
const adapter = new FileSystemAdapter({
basePath: './my-database',
});Storage Structure:
basePath/
dbPath/
collectionName/
docs/
{id}.json # Document files
index/
shard-00.json # Index shards
shard-01.json
...S3Adapter
AWS S3 storage adapter.
Constructor
typescript
new S3Adapter(config: StorageAdapterConfig)Parameters:
config.bucket- S3 bucket nameconfig.region- AWS region (e.g., 'us-east-1')config.credentials- AWS credentialsaccessKeyId- AWS access key IDsecretAccessKey- AWS secret access key
config.endpoint?- Optional custom endpoint (for LocalStack, MinIO, etc.)
Example:
typescript
import { S3Adapter } from '@bucket-db/core';
const adapter = new S3Adapter({
bucket: 'my-bucket',
region: 'us-east-1',
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
},
});OSSAdapter
Alibaba Cloud OSS storage adapter.
Constructor
typescript
new OSSAdapter(config: StorageAdapterConfig)Parameters:
config.bucket- OSS bucket nameconfig.region- OSS region (e.g., 'oss-cn-hangzhou')config.credentials- OSS credentialsaccessKeyId- OSS access key IDsecretAccessKey- OSS access key secret
config.endpoint?- Optional custom endpoint
Example:
typescript
import { OSSAdapter } from '@bucket-db/core';
const adapter = new OSSAdapter({
bucket: 'my-bucket',
region: 'oss-cn-hangzhou',
credentials: {
accessKeyId: process.env.OSS_ACCESS_KEY_ID!,
secretAccessKey: process.env.OSS_ACCESS_KEY_SECRET!,
},
});