c15t
/
C15T Logo
Select a version
Frameworks
Welcome to c15t Docs
Introduction to Consent Management (c15t)
AI Tools Integrations
OSS
Contributing to c15t.com
License
Building Privacy Tools in the Open
Legal
Cookie Policy
Privacy Policy
C15T Logo
HomeFrontendIntegrationsSelf HostChangelog
xbskydiscordgithub1.4k
c15t
/
C15T Logo
Select a version
Frameworks
Welcome to c15t Docs
Introduction to Consent Management (c15t)
AI Tools Integrations
OSS
Contributing to c15t.com
License
Building Privacy Tools in the Open
Legal
Cookie Policy
Privacy Policy
home-2Docs
chevron-rightSelf-host
chevron-rightV1
chevron-rightAdapters
chevron-rightMemory

Memory Adapter

The Memory adapter stores all data in-memory, making it perfect for development, testing, and prototyping. Data is lost when the application restarts.

Deprecated Feature

@c15t/backend v1 did not deliver the flexibility we wanted and fell short of our standards. It is now deprecated as we work on a full rewrite, with v2 entering canary soon. This does not affect consent.io deployments, which remain stable.

Installation

The Memory adapter is included in the core package and requires no additional dependencies:

import { memoryAdapter } from '@c15t/backend/db/adapters/memory';

Configuration

The Memory adapter accepts minimal configuration:

import { c15tInstance } from '@c15t/backend';
import { memoryAdapter } from '@c15t/backend/db/adapters/memory';

const instance = c15tInstance({
  baseURL: 'http://localhost:3000',
  database: memoryAdapter({
    // Optional: Pre-populate with initial data
    initialData: {
      users: [
        { id: '1', name: 'Admin User', email: 'admin@example.com' }
      ]
    },
    // Optional: Set persistence to localStorage in browser environments
    persistence: 'localStorage'
  }),
});

Usage Examples

Basic CRUD Operations

// Create a new record
const user = await instance.database.create('users', {
  name: 'John Doe',
  email: 'john@example.com'
});

// Find records
const users = await instance.database.find('users', {
  where: { email: 'john@example.com' }
});

// Update a record
const updatedUser = await instance.database.update(
  'users',
  { where: { id: user.id } },
  { name: 'John Smith' }
);

// Delete a record
await instance.database.delete('users', { where: { id: user.id } });

Best Practices

  • Use for development only - The memory adapter is not suitable for production use as data is lost on restart
  • Test with realistic data volumes - Pre-populate with a representative data set to test performance
  • Reset between tests - Create a new instance for each test to ensure a clean environment

Limitations

  • No persistence across application restarts
  • Not suitable for production environments
  • Limited query capabilities compared to SQL-based adapters
  • No support for complex joins or transactions

When to Use

  • During development and prototyping
  • For automated testing
  • For demos and examples
  • When you need a lightweight, zero-configuration database

Related Resources

  • Core Concepts
  • Database Adapter Interface
C15T Logo
Leverage native React components for seamless integration and high performance in a robust Consent Management solution that empowers your development team while prioritizing privacy and compliance.
Product
  • Documentation
  • Components
Company
  • GitHub
  • Contact
Legal
  • Privacy Policy
  • Cookie Policy
c15t