Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jwillp committed Nov 8, 2019
1 parent c914240 commit 33f9766
Showing 1 changed file with 54 additions and 3 deletions.
57 changes: 54 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,60 @@ YDB is a simple PHP utility library to use Yaml as a flat file databases

[![Build Status](https://travis-ci.com/Morebec/YDB.svg?branch=master)](https://travis-ci.com/Morebec/YDB)

## Usage
## Installation
To install the library in a project, add this to your `composer.json` file:

```json
{
// ...
"repositories": [
{
"url": "https://github.com/Morebec/YDB.git",
"type": "git"
}
],

"require": {
// ...
"morebec/ydb": "dev-master"
}
// ...
}
```

## Usage
### Create a Database
In order to create a database do the following:
A database can be created by doing the following:

```php
// Create a configuration object for the database
$config = new DatabaseConfig(
Directory::fromStringPath(__DIR__ . '/../_data/test-db')
);

// To enable logging
$config->enabledLogging();

// To disable indexing
$config->disableIndexing();

// Create the database
$database = new Database($config);
```

This would result in the following file structure at the directory of the database:

```
test-db/
logs/
tables/
table-1/
...
table-2/
...
```


### Create a Table
Tables are created using a `TableSchema` that defines the columns of the table.

Expand All @@ -35,7 +73,8 @@ $schema = new TableSchema('test-query-record', [
And to create the table:

```php
$table = $this->database->createTable($schema);
// This function will return a table object that can be used to be queried
$table = $database->createTable($schema);
```

### Create a Record
Expand Down Expand Up @@ -93,3 +132,15 @@ $query = QueryBuilder::find('first_name', Operator::STRICTLY_EQUAL(), 'James')
;
$r = $table->query($query);
```

## Running Tests

```bash
# Will run all tests including performance tests
composer test

# Will run all tests excluding performance tests
composer test-no-performance
```


0 comments on commit 33f9766

Please sign in to comment.