Skip to content

Storage classes

import {
AbstractStorage,
InMemoryStorage,
} from '@labdigital/commercetools-mock'
import { SQLiteStorage } from '@labdigital/commercetools-mock/sqlite'

The default backend. Construct with no arguments:

new InMemoryStorage()

See In-memory storage.

Experimental SQLite backend, from the /sqlite entry point.

new SQLiteStorage(options?: { filename?: string })
OptionDefaultDescription
filenamecommercetools-mock.dbDatabase file path, or ':memory:'.

Has a close() method to release the connection. See SQLite storage.

The base class to extend for a custom backend. Key abstract methods (all return Promises):

clear, all, count, add, get, getByKey, delete, query, addProject, getProject, saveProject, getByContainerAndKey, expand.

close() is a non-abstract no-op you can override if your backend holds external resources.