-
Notifications
You must be signed in to change notification settings - Fork 29
Closed
Description
Hi, I am trying to sort the data with sort key but it's not working.
Schema:
$schema = [
'AttributeDefinitions' => [
[
'AttributeName' => 'id',
'AttributeType' => 'S',
],
[
'AttributeName' => 'customer_id',
'AttributeType' => 'N',
],
[
'AttributeName' => 'created_at',
'AttributeType' => 'S',
],
],
'TableName' => $this->tableName,
'KeySchema' => [
[
'AttributeName' => 'id',
'KeyType' => 'HASH',
],
[
'AttributeName' => 'created_at',
'KeyType' => 'RANGE',
],
],
'StreamSpecification' => [
'StreamEnabled' => true,
'StreamViewType' => 'NEW_AND_OLD_IMAGES',
],
'GlobalSecondaryIndexes' => [
[
'IndexName' => 'gsi_0',
'Projection' => [
'ProjectionType' => 'ALL',
],
'KeySchema' => [
[
'AttributeName' => 'customer_id',
'KeyType' => 'HASH',
],
[
'AttributeName' => 'created_at',
'KeyType' => 'RANGE',
],
],
'BillingMode' => 'PAY_PER_REQUEST',
],
],
'BillingMode' => 'PAY_PER_REQUEST',
];
Model:
class AuditLog extends Model
{
protected $connection= 'dynamodb';
protected $table = "";
protected $primaryKey = 'id';
protected $sortKey = 'created_at';
protected $fillable = ["id", "log_text", "customer_id", "created_at"];
}
Controller:
$data = AuditLog::limit(5)->scanIndexForward(false)->scan();
$response = [
"success" => true,
"data" => $data,
];
return response($response, 201);
Metadata
Metadata
Assignees
Labels
No labels