Skip to content

Commit 9cdcfc9

Browse files
committed
Update README
1 parent 8db9028 commit 9cdcfc9

File tree

1 file changed

+46
-2
lines changed

1 file changed

+46
-2
lines changed

README.md

+46-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ Supports all key types - primary hash key and composite keys.
1313
1414
* [Install](#install)
1515
* [Usage](#usage)
16+
* [find() and delete()](#find-and-delete)
17+
* [Conditions](#conditions)
18+
* [all() and first()](#all-and-first)
19+
* [Update](#update)
20+
* [Save](#save)
21+
* [Chunk](#chunk)
22+
* [limit() and take()](#limit-and-take)
23+
* [firstOrFail()](#firstorfail)
24+
* [findOrFail()](#findorfail)
25+
* [Query scope](#query-scope)
1626
* [Indexes](#indexes)
1727
* [Composite Keys](#composite-keys)
1828
* [Requirements](#requirements)
@@ -32,7 +42,7 @@ Install
3242

3343
```php
3444
// config/app.php
35-
45+
3646
'providers' => [
3747
...
3848
BaoPham\DynamoDb\DynamoDbServiceProvider::class,
@@ -73,7 +83,7 @@ Usage
7383
* 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.
7484
* 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.
7585
76-
### Supported methods:
86+
### Supported features:
7787
7888
#### find() and delete()
7989
@@ -195,6 +205,40 @@ $model->findOrFail('foo');
195205
$model->findOrFail(['id' => 'foo', 'id2' => 'bar']);
196206
```
197207
208+
#### Query Scope
209+
210+
```php
211+
class Foo extends DynamoDbModel
212+
{
213+
protected static function boot()
214+
{
215+
parent::boot();
216+
217+
static::addGlobalScope('count', function (DynamoDbQueryBuilder $builder) {
218+
$builder->where('count', '>', 6);
219+
});
220+
}
221+
222+
public function scopeCountUnderFour($builder)
223+
{
224+
return $builder->where('count', '<', 4);
225+
}
226+
227+
public function scopeCountUnder($builder, $count)
228+
{
229+
return $builder->where('count', '<', $count);
230+
}
231+
}
232+
233+
$foo = Foo();
234+
// Global scope will be applied
235+
$foo->all();
236+
// Local scope
237+
$foo->withoutGlobalScopes()->countUnderFour()->get();
238+
// Dynamic local scope
239+
$foo->withoutGlobalScopes()->countUnder(6)->get();
240+
```
241+
198242
Indexes
199243
-----------
200244
If your table has indexes, make sure to declare them in your model class like so

0 commit comments

Comments
 (0)