Skip to content

Quick CRUD reference

Related: First steps · Installation and building · Textbook: Volume I "Fundamentals" · C API reference

This is a compact cheat-sheet for the most common operations. The authoritative Quick Reference with the full decision tables is generated from the mdbx.h annotations and lives in the C API reference:

C++ API at a glance

The C++ binding maps the C operations onto mdbx::txn and mdbx::cursor methods. The most common ones:

Operation mdbx::txn mdbx::cursor C equivalent
Insert or fail insert(map, key, value) insert(key, value) mdbx_put(MDBX_NOOVERWRITE)
Insert or replace upsert(map, key, value) upsert(key, value) mdbx_put(MDBX_UPSERT)
Update existing update(map, key, value) update(key, value) mdbx_put(MDBX_CURRENT)
Read get(map, key) to_first()/to_find()/... mdbx_get()
Read & remove extract(map, key) — mdbx_replace()
Delete by key erase(map, key) erase(key) mdbx_del()
Delete pair erase(map, key, value) erase(key, value) mdbx_del()
Append (tail) put(map, key, value, MDBX_APPEND) put(key, value, MDBX_APPEND) mdbx_put(MDBX_APPEND)

See the full reference in the C++ API and cursor pages.

Examples

Further reading