2017 © Pedro Peláez
 

library dynamodb

DynamoDb wrapper for your Laravel model and helpers

image

slava-ponomarenko/dynamodb

DynamoDb wrapper for your Laravel model and helpers

  • Thursday, May 5, 2016
  • by slava-ponomarenko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 48 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

laravel-dynamodb

Supports all key types - primary hash key and composite keys., (*1)

Install

  • Composer install, (*2)

    composer require baopham/dynamodb:0.2.2
    
  • Install service provider:, (*3)

    // config/app.php
    
    'providers' => [
        ...
        BaoPham\DynamoDb\DynamoDbServiceProvider::class,
        ...
    ];
    
  • Put DynamoDb config in config/services.php:, (*4)

    // config/services.php
        ...
        'dynamodb' => [
            'key' => env('DYNAMODB_KEY'),
            'secret' => env('DYNAMODB_SECRET'),
            'region' => env('DYNAMODB_REGION'),
            'local_endpoint' => env('DYNAMODB_LOCAL_ENDPOINT'), // see http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Tools.DynamoDBLocal.html
            'local' => env('DYNAMODB_LOCAL'), // true or false? should use dynamodb_local or not?
        ],
        ...
    

Usage

  • Extends your model with BaoPham\DynamoDb\DynamoDbModel, then you can use Eloquent methods that are supported. The idea here is that you can switch back to Eloquent without changing your queries.

Supported methods:, (*5)

// find and delete
$model->find(<id>);
$model->delete();

// Using getIterator(). If 'key' is the primary key or a global/local index and the condition is EQ, will use 'Query', otherwise 'Scan'.
$model->where('key', 'key value')->get();

// See BaoPham\DynamoDb\ComparisonOperator
$model->where(['key' => 'key value']);
// Chainable for 'AND'. 'OR' is not supported.
$model->where('foo', 'bar')
    ->where('foo2', '!=' 'bar2')
    ->get();

// Using scan operator, not too reliable since DynamoDb will only give 1MB total of data.
$model->all();

// Basically a scan but with limit of 1 item.
$model->first();

// update
$model->update($attributes);

$model = new Model();
// Define fillable attributes in your Model class.
$model->fillableAttr1 = 'foo';
$model->fillableAttr2 = 'foo';
// DynamoDb doesn't support incremented Id, so you need to use UUID for the primary key.
$model->id = 'de305d54-75b4-431b-adb2-eb6b9e546014'
$model->save();
  • Or if you want to sync your DB table with a DynamoDb table, use trait BaoPham\DynamoDb\ModelTrait, it will call a PutItem after the model is saved.

Composite Keys

To use composite keys with your model:, (*6)

  • Set $compositeKey to an array of the attributes names comprising the key, e.g.
protected $primaryKey = ['customer_id'];
protected $compositeKey = ['customer_id', 'agent_id'];
  • To find a record with a composite key
$model->find(['id1' => 'value1', 'id2' => 'value2']);

Test

Run:, (*7)

$ java -Djava.library.path=./DynamoDBLocal_lib -jar dynamodb_local/DynamoDBLocal.jar --port 3000
$ ./vendor/bin/phpunit
  • DynamoDb local version: 2015-07-16_1.0, (*8)

  • DynamoDb local schema for tests created by the DynamoDb local shell is located here, (*9)

Requirements

Laravel ^5.1, (*10)

TODO

  • [ ] Upgrade a few legacy attributes: AttributesToGet, ScanFilter, ...

License

MIT, (*11)

Author and Contributors

The Versions

05/05 2016

dev-master

9999999-dev

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

05/05 2016

0.2.2

0.2.2.0

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

02/05 2016

dev-query-builder

dev-query-builder

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

09/04 2016

0.2.1

0.2.1.0

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

28/02 2016

dev-test-travis

dev-test-travis

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

27/02 2016

0.2.0

0.2.0.0

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

08/02 2016

dev-compositekeys

dev-compositekeys

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

05/01 2016

0.1.2

0.1.2.0

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

22/11 2015

dev-aws-sdk-v2

dev-aws-sdk-v2

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

22/11 2015

0.1.1

0.1.1.0

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel aws dynamodb

04/08 2015

0.1.0

0.1.0.0

DynamoDb wrapper for your Laravel model and helpers

  Sources   Download

MIT

The Requires

 

The Development Requires