Extend the DynamoDB Model class
mainThe Kitar\Dynamodb\Model\Model class extends Eloquent, allowing you to use mutators and serialization. However, unlike standard Eloquent, it forwards calls to the DynamoDB Query Builder instead of a relational query builder, and it cannot handle relations.
Required and Optional Attributes
| Name | Required | Description |
|---|---|---|
table | yes | Name of the Table. |
primaryKey | yes | Name of the Partition Key. |
sortKey | Name of the Sort Key. | |
sortKeyDefault | Default value for the Sort Key. |
Implementation Examples
Table with only a Partition Key:
use Kitar\Dynamodb\Model\Model;
class ProductCatalog extends Model
{
protected $table = 'ProductCatalog';
protected $primaryKey = 'Id';
protected $fillable = ['Id', 'Price', 'Title'];
}Table with a Sort Key:
class Thread extends Model
{
protected $table = 'Thread';
protected $primaryKey = 'ForumName';
protected $sortKey = 'Subject';
protected $fillable = ['ForumName', 'Subject'];
}Table with a Sort Key and a Default Sort Key:
If sortKeyDefault is set, it will be used when instantiating or calling find() without providing a sort key.
class User extends Model
{
protected $table = 'User';
protected $primaryKey = 'email';
protected $sortKey = 'type';
protected $sortKeyDefault = 'profile';
protected $fillable = ['name', 'email', 'password', 'type'];
}