You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Kitar\Dynamodb\Model\Model` is a experimental Model implementation for this package.
295
+
`Kitar\Dynamodb\Model\Model` is an experimental Model implementation for this package.
294
296
295
-
It works like Eloquent Model, but there is no model querying features. Model's features to interact DynamoDB is only `save`, `update` and `delete`.
297
+
It works like Eloquent Model, but instead of forwarding calls to "Model" Query, we forward call directly to "DynamoDB" Query.
296
298
297
-
Instead we don't have model query, we'll tell the QueryBuilder to instantiate DynamoDBresponse with the specified model.
299
+
Because there is no "Model" Query, we can't use handy methods like `find``create``firstOrCreate` or something like that. We only have `save``update` and `delete` for the Model methods to interact with DynamoDB. However, when we query through Model, DynamoDB's response items will be automatically converted to the model instance.
298
300
299
-
### Binding model to the QueryBuilder
301
+
### Basic Usage of Model
300
302
301
-
For example, we have some user model below.
303
+
Let's say we have some Authenticatable User model. (we'll use this example in the Authentication section as well)
304
+
305
+
Most attributes are the same as the original Eloquent Model, but there are few DynamoDB specific attributes. `table``primaryKey``sortKey` and `sortKeyDefault`.
302
306
303
307
```php
304
308
<?php
@@ -349,35 +353,52 @@ class User extends Model implements AuthenticatableContract
349
353
}
350
354
```
351
355
352
-
Then, let QueryBuilder know model class by `usingModel`.
`$response['Item']` will be the User model instance.
364
+
$user = $response['Item'];
365
+
```
364
366
365
-
> behind the scene when specifying `usingModel`, Query Processor is converting each items to model instance with `(new $modelClass)-newFromBuilder($item)`.
367
+
```php
368
+
$response = User::filter('type', '=', 'profile')
369
+
->scan();
366
370
367
-
After retrieving the model instance, we can `save`, `update` and `delete` in the same manner as Eloquent Model.
0 commit comments