npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@websolutespa/payload-db-memory

v3.0.2

Published

Data-agnostic in-memory database adapter for Payload with seeding and hot reload

Readme

Payload DB Memory Adapter

A data-agnostic, in-memory database adapter for Payload 3.x.

It lets you develop an app or website without a real database. The adapter keeps Payload documents in process memory and implements the Payload database interface for collections, globals, versions, drafts, counts, distinct queries, and jobs.

This package does not include built-in seeding or hot reload. If you want to preload data, use a separate plugin such as @websolutespa/payload-plugin-seed or write to the adapter through Payload APIs or the exposed in-memory models.

Why

  • Zero infrastructure: no MongoDB or Postgres required for local development.
  • Data agnostic: works with any collection or global schema and stores documents in Payload's database shape.
  • Full adapter: implements the Payload BaseDatabaseAdapter interface.
  • Ecosystem compatible: exposes lightweight collection and version models for tools that call payload.db.collections[slug].bulkWrite(...) or .countDocuments().

Installation

npm install @websolutespa/payload-db-memory

Usage

import { buildConfig } from 'payload'
import { memoryAdapter } from '@websolutespa/payload-db-memory'

export default buildConfig({
  // ...rest of config
  db: memoryAdapter(),
})

You can also customize how IDs are generated for newly created documents:

memoryAdapter({
  defaultIDType: 'number',
  allowIDOnCreate: true,
})

Data model

Documents are stored in Payload's database shape, like the SQL and Mongo adapters:

  • Localized fields are stored as locale-keyed objects, for example { en: 'Hello', it: 'Ciao' }.
  • Relationships are stored as an id, or as { relationTo, value } for polymorphic relations.

Payload still resolves locale flattening on read.

Populating data

This adapter starts empty. You can populate it in three ways:

  1. Use normal Payload operations such as payload.create, payload.update, and payload.updateGlobal.
  2. Use a dedicated seeding plugin such as @websolutespa/payload-plugin-seed.
  3. Use the Mongo-like in-memory models exposed on payload.db.collections[slug] and payload.db.versions[slug].

Example:

await payload.create({
  collection: 'posts',
  data: {
    title: 'Hello',
  },
})

Options

memoryAdapter({
  /** 'text' (default) or 'number' generated IDs. */
  defaultIDType?: 'number' | 'text'
  /** Allow caller-provided ids on create. Default false. */
  allowIDOnCreate?: boolean
})

defaultIDType

  • 'text' generates a Mongo-like 24 character hex id.
  • 'number' generates progressive numeric ids scoped per slug.

allowIDOnCreate

When true, explicit ids passed to create flows are accepted.

Ecosystem compatibility

Some Payload ecosystem utilities write directly to the underlying model instead of using high-level Payload CRUD APIs. This adapter exposes lightweight in-memory models on payload.db.collections and payload.db.versions with:

  • bulkWrite(...)
  • countDocuments()

That keeps utilities such as static i18n collection loaders and cron-related jobs from crashing when they expect a Mongo-like model surface.

Unregistered slugs resolve to undefined gracefully.

Supported query features

The in-memory query engine supports Payload where clauses (and / or and the operators equals, not_equals, in, not_in, all, exists, like, contains, greater_than[_equal], less_than[_equal]), locale-aware field resolution, relationship id matching, sorting (sort / -sort), pagination, select projections, and findDistinct.

Not supported: geospatial operators (near, within, intersects) are treated as no-ops, and relationship join queries are not resolved.

Advanced / internal API

Power users and tests can import the internal building blocks:

import {
  buildWhere,
  clone,
  createStore,
  paginate,
  sortDocs,
} from '@websolutespa/payload-db-memory/internal'

Limitations

  • Data lives in process memory and is lost on restart.
  • No real transactions: begin, commit, and rollback are no-ops.
  • No persistent migrations: createMigration is a no-op.
  • migrateFresh clears the in-memory store; it does not reseed anything.

Intended for development and testing, not production.