AmberDB
view release on metacpan or search on metacpan
docs/EN.About_AmberDB.md view on Meta::CPAN
[ð Home](index.html) ⢠[ð About](EN.About_AmberDB.html) ⢠[ð Quick Start](index.html#-quick-start) ⢠[ð Tutorial](EN.AmberDB_User-Guide.html) ⢠[ð Locale](EN.AmberDB-Locale_User-G...
---
# About
**AmberDB** is an embedded NoSQL database engine for Perl that processes Array-based records supporting JSON-like nested and complex structures. Thanks to custom indexes generated through schema definitions, it performs block matching, querying, full...
It is built on the C code of Berkeley DB (`DB_File`) provided by the standard Perl package and does not use any other database engine. `DB_File` is Berkeley DB's low-level interface that provides key-value access via Perl. AmberDB constructs a data m...
---
## Why AmberDB?
AmberDB brings together diverse capabilities within a single Perl database engine:
* **No External Database Server:** Embedded directly into the application as an in-process object.
* **Array-Based Records:** Database records are Arrays (lists) supporting JSON-like nested structures.
* **Full CRUD Operations:** Fast, direct insert, read, update, and delete methods.
* **Flexible Indexing:** Operates seamlessly both with and without indexes. Requires no separate setup for indexing.
* **Full-Text Search:** High-performance search (both indexed and unindexed).
* **Sorting & Versatile Queries:** Multi-field sorting, range queries, and regex filtering.
* **Nested & Repeating Blocks:** Automatic management of relational and repeating data blocks.
* **Multi-Table Relational Transactions:** ACID-compliant transaction management with Strict 2-Phase Locking (Strict 2PL).
* **Faceted Filtering:** Dynamic faceted filtering generation, just like on modern e-commerce sites.
* **RAM-to-Disk Tiering:** RAM buffer caching layer similar to Redis.
* **High-Throughput Batch Processing:** Dedicated bulk ingestion and index-merge pipeline.
* **Audit Logging:** Built-in logging of user operations on each record.
* **Soft Deletes:** Table-definition-specific soft delete (stores deleted records in an archive tier).
* **Automatic SEO Slugs:** Automatic URL slug generation for catalog tables.
* **Portable Backups:** Portable `.amberdb` database archives and restore tools with SHA-256 verification.
> **Core Principle:**
> The database should make common application data operations simple, fast, and predictable.
---
## Quick Introductory Example
```perl
use strict;
use warnings;
use AmberDB;
# 1. Create AmberDB instance
my $adb = AmberDB->new(
cfg => { user => 'admin', language => 'en' },
path => { dbase_dir => './dbstore' }
);
# 2. Define product record
my @product = (
0, # id (0 for auto-increment)
"Wireless Headphones", # name
149.99, # price
"Sony", # brand
"Electronics", # category
{ status => "In Stock" } # status hash ref
);
# 3. Insert the product record into the "products" table
my $id = $product[0] = $adb->insert_id(
"products", # table
@product # record
);
# 4. Reading the record back:
my @product_fromdb = $adb->read_id("products", $id);
# Print the record read from the database
print "Price: $product_fromdb[2], Status: $product_fromdb[5]->{status}\n";
# 5. Modification:
$product[2] = 129.99; # Assign a new value to block #2 and update the record using modify_id
$adb->modify_id("products", @product);
# 6. Search:
# AmberDB's `search_table` method locates terms appearing deep within lists, hash keys, and values.
my @search_result = $adb->search_table("products", "sony electronics headphones");
foreach my $product (@search_result) {
( run in 3.379 seconds using v1.01-cache-2.11-cpan-aadc1410aed )