Search by

byjg / anydataset-nosql

byjg

Anydataset NoSQL standardizes the access to non-relational databases/repositories and provides a consistent interface for both NoSQL document databases and Key/Value stores.

Package info

github.com/byjg/php-anydataset-nosql

pkg:composer/byjg/anydataset-nosql

Statistics

Installs: 9 918

Dependents: 0

Suggesters: 0

Stars: 7

Open Issues: 0

6.0.0 2025-11-24 18:03 UTC

This package is auto-updated.

Last update: 2026-10-25 23:50:25 UTC


README

sidebar_key anydataset-nosql
sidebar_category data-access
tags
php anydataset databases

NoSQL Database Abstraction

One interface for document databases and one for key/value stores, whatever the service behind them. The implementation supports:

Sponsor Build Status Opensource ByJG Install MCP Server GitHub source GitHub license GitHub release

  • MongoDB (document-based)
  • AWS DynamoDB (key/value)
  • S3-Like Storage (key/value)
  • Cloudflare KV (key/value)

Anydataset is an agnostic data source abstraction layer in PHP. See more about Anydataset here.

Why

MongoDB, DynamoDB, S3 and Cloudflare KV each come with their own SDK and their own way to read, write and list. Storing a file in S3 today and in Cloudflare KV tomorrow means rewriting every call.

Anydataset NoSQL defines two contracts, NoSqlInterface for documents and KeyValueInterface for key/value stores, and picks the service from the connection URI:

$store = Factory::getInstance('s3://key:secret@us-east-1/my-bucket');        // AWS S3
$store = Factory::getInstance('kv://user:token@account/namespace');          // Cloudflare KV
$store = Factory::getInstance('dynamodb://key:secret@host/table');           // DynamoDB

$store->put('invoice-42', $pdf);
$pdf = $store->get('invoice-42');
  • Change the service with the URI, not the code that uses it.
  • Same iterator as the rest of AnyDataset. getIterator() returns the same rows as a database or a file, and document queries use the same IteratorFilter.

Features

  • Access both document-based and key/value repositories with consistent interfaces
  • NoSQL document-based databases accessed through NoSqlInterface
  • Key/Value stores accessed through KeyValueInterface
  • Unified connection string format based on URIs
  • Type-safe DynamoDB attribute definitions using enums

Connection Based on URI

The connection string for databases is based on URL.

See below the current implemented drivers:

Datasource Connection String
MongoDB mongodb://username:password@hostname:port/database
S3 s3://accesskey:secretkey@region/bucket?params
Cloudflare KV kv://username:password@accountid/namespaceid
AWS DynamoDB dynamodb://accesskey:secretkey@hostname/tablename?params

Documentation

NoSQL Drivers

  • MongoDB - Document-based NoSQL database

Key/Value Drivers

  • AWS DynamoDB - Key/Value store with type-safe attribute definitions
  • AWS S3 - Object storage as Key/Value store
  • Cloudflare KV - Cloudflare Workers KV storage

Additional Features

Installation

Just type:

composer require "byjg/anydataset-nosql"

Running Tests

docker compose up -d
vendor/bin/phpunit

More details are in Running Tests.

Open source ByJG