2017 © Pedro PelĂĄez
 

library yaysondb

Flat file db storing data as json arrays

image

hanneskod/yaysondb

Flat file db storing data as json arrays

  • Monday, December 11, 2017
  • by hanneskod
  • Repository
  • 2 Watchers
  • 2 Stars
  • 671 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 1 % Grown

The README.md

Yaysondb

Packagist Version Build Status Quality Score, (*1)

Flat file db in pure php., (*2)

Why?

Partly as a learning exercise, partly since I needed a simple and PHP only DB for some cli scripts., (*3)

Features

Installation

composer require hanneskod/yaysondb

Usage

Setup

Yaysondb works as a handler for multiple collections., (*4)

use hanneskod\yaysondb\Yaysondb;
use hanneskod\yaysondb\Engine\FlysystemEngine;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;

$db = new Yaysondb([
    'table' => new FlysystemEngine(
        'data.json',
        new Filesystem(new Local('path-to-files'))
    )
]);

Access collection through property or collection(), (*5)

$db->table === $db->collection('table');

Create

$db->table->insert(['name' => 'foobar']);

Transactions

Commit or rollback changes using commit(), reset() and inTransaction(), (*6)

$db->table->commit();

Concurrency protection

Yaysondb supports limited concurrency protection when using the flysystem engine. A hash of the backend file is calculated at each read and any write action will fail if the hash has changed., (*7)

Read

Create search documents using the Operators class., (*8)

use hanneskod\yaysondb\Operators as y;

// Find all documents with an address in new york
$result = $db->table->find(
    y::doc([
        'address' => y::doc([
            'town' => y::regexp('/new york/i')
        ])
    ])
);

// The result set is filterable
foreach ($result->limit(2) as $id => $doc) {
    // iterate over the first 2 results
}

The search document

The following operators are available when creating search documents:, (*9)

Operator Description
doc(array $query) Evaluate documents and nested subdocuments
not(Expr $e) Negate expression
exists() Use to assert that a document key exists
type($type) Check if operand is of php type
in(array $list) Check if operand is included in list
regexp($reg) Check if operand matches regular expression
equals($op) Check if operands equals each other
same($op) Check if operands are the same
greaterThan($op) Check if supplied operand is greater than loaded operand
greaterThanOrEquals($op) Check if supplied operand is greater than or equals loaded operand
lessThan($op) Check if supplied operand is less than loaded operand
lessThanOrEquals($op) Check if supplied operand is less than or equals loaded operand
all(Expr ...$e) All contained expressions must evaluate to true
atLeastOne(Expr ...$e) At least one contained expressions must evaluate to true
exactly($c, Expr ...$e) Match exact number of contained expressions evaluating to true
none(Expr ...$e) No contained expressions are allowed evaluate to true
one(Expr ...$ex) Exactly one contained expressions must evaluate to true
listAll(Expr $e) Expression must evaluate to true for each list item
listAtLeastOne(Expr $e) Expression must evaluate to true for at least one list item
listExactly($c, Expr $e) Expression must evaluate to true for exact numer of items in list
listNone(Expr $e) Expression is not allowed to evaluate to true for any list item
listOne(Expr $e) Expression must evaluate to true for exactly one list item

Update

Collection::update() takes two arguments. A search document and an array of values. Documents matching the search document are updated with the supplied values., (*10)

Delete

Collection::delete() takes a search document as sole argument. Documents matching the search document are removed., (*11)

The Versions

11/12 2017

2.0.x-dev

2.0.9999999.9999999-dev https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Hannes ForsgÄrd

database json nosql jsondb

11/12 2017

dev-hanneskod-patch-1

dev-hanneskod-patch-1 https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Hannes ForsgÄrd

database json nosql jsondb

30/10 2017

2.1.2

2.1.2.0 https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Hannes ForsgÄrd

database json nosql jsondb

12/09 2017

2.1.1

2.1.1.0 https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Hannes ForsgÄrd

database json nosql jsondb

05/07 2017

2.1.0

2.1.0.0 https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Hannes ForsgÄrd

database json nosql jsondb

19/01 2017

2.0.0

2.0.0.0 https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

 

The Development Requires

by Hannes ForsgÄrd

database json nosql jsondb

23/09 2016

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

  • php >=5.6

 

by Hannes ForsgÄrd

database json nosql jsondb

16/10 2014

1.0.0

1.0.0.0 https://github.com/hanneskod/yaysondb

Flat file db storing data as json arrays

  Sources   Download

WTFPL

The Requires

  • php >=5.6

 

by Hannes ForsgÄrd

database json nosql jsondb