Open joelatgrayv opened 5 months ago
I have a feeling your model is not using the DynamoDb connection. Try to hard code the connection in your model
protected $connection = 'dynamodb';
Sorry, I should have included my base model. It does have protected $connection = 'dynamodb';
. I'll revise the example. You can see that the single model creation works in the seeder class but the factory create function throws the error.
// This works
$model = new ExampleDynamoDbModel();
$model->my_primary_key = rand();
$model->my_sort_key = rand();
$model->save();
// This throws the error
$data = ExampleDynamoDbModel::factory()->count(1)->create();
The Factory was overriding the $connection in the model. For me I additionally had to revise the setConnection method to prevent this:
protected $connection = 'dynamodb';
public function setConnection($name)
{
// Don't override the $connection
// $this->connection = $name;
return $this;
}
Should the Factories work? I get this error:
Call to undefined method Illuminate\Database\Query\Builder::usingModel()
The entry ends up in the local dynamodb but an error is thrown.
Model
Factory
Seeder
Error Message