Comments (55)
that sounds more like you didn't setup things right :
Can you give me your model class?
from laravel-dynamodb.
Thanks for the response, Im on L5.4, here is my model:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Messages extends \BaoPham\DynamoDb\DynamoDbModel
{
protected $table = 'Billing_messages';
}
from laravel-dynamodb.
and what is your primary key in your DynamoDB table?
from laravel-dynamodb.
Primary: id (String), sort: create_at (String)
from laravel-dynamodb.
can you give me the code that causes the error?
from laravel-dynamodb.
is a 2 part code, one gets where I get the error
$message3 = Messages::find(1);
The second saves, this one doesn't give an error but it doesn't save anything on the table AWS console
$message = new Messages;
$message->id = uniqid('', true);
$message->save();
from laravel-dynamodb.
So:
-
$message3 = Messages::find(1);
gives you error? are you passing in a string or a number? looks like your primary key should be string instead. -
Are you sure your table only needs the
id
? you should fill in all other columns especially,create_at
from laravel-dynamodb.
this is an example of the table:
{
"content": "TAMBIEN claro que si\n\npero con return?",
"create_at": "2017-01-21 00:24:11",
"files": [
"the-file.jpg"
],
"from": 1,
"id": "1",
"order_id": 1
}
from laravel-dynamodb.
Right, so make sure when you set your id, it is a string.
Have you tried my suggestion 2?
from laravel-dynamodb.
Your suggestion No. 2 works, created_at what necessary to save, what do you think about the $message3 = Messages::find(1); is still showing the error
from laravel-dynamodb.
Try $message3 = Messages::find('1')
You're passing in a number so it wouldn't parse correctly.
from laravel-dynamodb.
even with $message3 = Messages::find('1'); I get the same error
from laravel-dynamodb.
do you have another record that you can test? Something that is not a number.
from laravel-dynamodb.
ok, I tried
- $message3 = Messages::where('order_id', '1')->first(); I got null (no error)
- $message3 = Messages::where('order_id', 1)->first(); I got error "MassAssignmentException in Model.php line 225: content"
from laravel-dynamodb.
let me try with created_at witch is a string
I got null
from laravel-dynamodb.
No. I meant do you have another ID that is not exactly a number and use that to test find
from laravel-dynamodb.
but the id is a (String) and sort: create_at (String)
I tried with content = "TAMBIEN claro que si\n\npero con return?" and got null
from laravel-dynamodb.
Sorry but I don't understand what you meant. Can you be more clear in your response?
Find some ID (primary key) that is more like a UUID and not a numeric.
from laravel-dynamodb.
ok , I saw a typo, I put in the table create_at missing the D, so I tried
$message3 = Messages::where('create_at', '2017-01-21 00:24:11')->first();
and got the same MassAssignmentException in Model.php line 225:
Im just trying to use where with multiple fields
from laravel-dynamodb.
There are a few things and I have no idea what you are asking:
$message3 = Messages::find(1)
or$message3 = Messages::find('1')
which I kept asking you to try a different ID.$message3 = Messages::where('create_at', '2017-01-21 00:24:11')->first();
which I think you already solved it by fixing the typo.
So I'm really confused about what you are asking.
from laravel-dynamodb.
is the same thing, I can't query any results, they all show null or "MassAssignmentException in Model.php line 225: content" error
Im able to save, but not get any records
sorry
from laravel-dynamodb.
Try to setup your fillable attributes in your model:
$fillable = ['create_at', 'order_id', ...]
from laravel-dynamodb.
I always thought fillable was just for saving, but it works :) , now this 2 work:
$message2 = Messages::where('create_at', '2017-01-21 00:24:11')->first();
$message3 = Messages::where('create_at', '567')->get();
but find by id still doesn't :
$message1 = Messages::find('58badb381838c5.44840949'); OR
$message1 = Messages::where('id', '1')->first();
they still produce the same error as my first message (DynamoDbException)
from laravel-dynamodb.
I always thought fillable was just for saving
Ah yeah, I'm using Model::fill
to give you back the model object so that's why you're getting the mass assignment error. I should use a different method though.
Do you have a stack trace for me?
from laravel-dynamodb.
Sorry I don't understand what "stack trace" is, but the logs in laravel don't show any error, I tried with other fields and it works, maybe I shouldn't name the primary "id" but something like "my_id"
from laravel-dynamodb.
thanks
from laravel-dynamodb.
You are not using composite key, are you?
from laravel-dynamodb.
All my model file is what I send you (+ the fillable), I don't think Im using a composite key
from laravel-dynamodb.
ok, I change the primary to primary_id and it work better, anyway found an error with this (“) “primary_id" in the json, so that might been the error?
Anyway $message1 = Messages::where('primary_id', '1')->first(); now works
but $message0 = Messages::find('1') still doesn't, but I can manage with the first one
from laravel-dynamodb.
hmmm try to define your primary key in your model?
protected $primaryKey = ['primary_id'];
from laravel-dynamodb.
I have a feeling that your table doesn't have the correct primary key.
from laravel-dynamodb.
I get error: Illegal offset type in isset or empty
from laravel-dynamodb.
Stack trace please?
from laravel-dynamodb.
Thanks
from laravel-dynamodb.
DynamoDbQueryBuilder->find(1)
<--- this is why I would like you to try a different ID value that is not a numeric. E.g. Message::find('abcdefg')
. Additionally, can you give me your updated model class and confirm what is your primary key now? is it id
or primary_id
?
from laravel-dynamodb.
class Messages extends \BaoPham\DynamoDb\DynamoDbModel
{
protected $table = 'messages';
protected $fillable = ['create_at', 'order_id', 'content', 'files', 'primary_id', 'from'];
protected $primaryKey = ['primary_id'];
from laravel-dynamodb.
in controller
$message = Messages::find('1');
from laravel-dynamodb.
Thanks. Now can you try a different ID value please? Nothing numeric.
from laravel-dynamodb.
I tried $message = Messages::find('hello'); same error
baopham with the DB in digital ocean Im getting an execution time of 0.025 and with Dynamo on AWS Im getting a 0.19 is this normal? I thought Dynamo was faster or is just local vs aws servers
from laravel-dynamodb.
$message = Messages::find('hello'); same error
Ok, I will have to find sometime and reproduce this.
with the DB in digital ocean Im getting an execution time of 0.025 and with Dynamo on AWS Im getting a 0.19 is this normal?
Umm, I don't understand. Are you testing all locally?
I thought Dynamo was faster
Depends really on how you design your tables.
is just local vs aws servers
Requests made from local environment tend to be slower.
from laravel-dynamodb.
When I mean local I mean the same DB in the digital ocean server where the app is running
Im getting the execution time with
$message = Messages::where('primary_id', '1')->first();
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
echo "Process Time sql: {$time}";
and then in another link Im using the Digital Ocean db
from laravel-dynamodb.
I'm afraid that this question is out of scope of this library. There are a lot of factors to take into account and I don't know how your DB, server, etc. are setup.
from laravel-dynamodb.
true, well I would like to thanks you for your help B, appreciate it a lot
from laravel-dynamodb.
No problem. As for the Message::find(...)
error, I will try to reproduce it on my end but probably won't be able to until next weekend.
from laravel-dynamodb.
Sorry, couldn't find the time to work on this... I'll leave this open for now
from laravel-dynamodb.
Hi baopham, hope your ok, I was wondering, did you ever find a fix for the error?
Error executing "GetItem" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error: POST https://dynamodb.us-east-1.amazonaws.com
resulted in a 400 Bad Request
response:
{"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema" (truncated...)
ValidationException (client): The provided key element does not match the schema - {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema"}
fit happens with both
$message = Messages::find('59822b2cda8650.74115649');
and
$message = Messages::where('id', $id);
Appreciate the help
from laravel-dynamodb.
Hi baopham, I found a way :), once a gain thanks for the great package
from laravel-dynamodb.
Great! Congrats! Closing issue.
from laravel-dynamodb.
@nam-co Would you be able to share your solution? having the same issue
from laravel-dynamodb.
Hi @kriiv tone honest I don't remember, it was like a year a go, but to be honest at the end I choose to use a regular mysql instead of AWS
from laravel-dynamodb.
@kriiv feel free to create a new issue.
from laravel-dynamodb.
Hi baopham, hope your ok, I was wondering, did you ever find a fix for the error?
Error executing "GetItem" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error:
POST https://dynamodb.us-east-1.amazonaws.com
resulted in a400 Bad Request
response:
{"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema" (truncated...)
ValidationException (client): The provided key element does not match the schema - {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema"}
fit happens with both
$message = Messages::find('59822b2cda8650.74115649');
and
$message = Messages::where('id', $id);Appreciate the help
Hi @nam-co and @baopham , i'm stiil facing this above error issue for find and where query. Can you please help me out to resolve issue or error?
from laravel-dynamodb.
Can you post your code where you call the query?
from laravel-dynamodb.
Hi I choose to use a regular mysql instead of AWS because all this problems, this is an old issue, But I see people are still having the same issues
from laravel-dynamodb.
Sorry I meant to tag @krupali-mbarc as they asked the question two days ago on a four year old thread, not the author of the original thread. Hundreds of thousands of queries are made using this framework so I’m not convinced that there is an issue here, other than not understanding how it works. Sorry it didn’t work out for you.
from laravel-dynamodb.
Related Issues (20)
- Combination of wherIn() and update() not working HOT 2
- I can't sort the items on a query HOT 3
- Could you fix this code? (PHP5.6 FatalError Analyzer.php ) HOT 1
- Issue using Nested attributes HOT 1
- Could I use AssumeRole with baopham dynamodb? HOT 2
- Force KeyCondition when filtering by only partition key in a table with a composite key HOT 1
- Add DAX Client HOT 1
- Pagination HOT 3
- DynamoDbModel constructor is not calling the `initializeTraits()` method like the parent HOT 1
- Unable to update data using where() HOT 6
- dynamodb.php not recognized HOT 1
- How to use 'Sort descending' HOT 1
- How to query List\Map Key-Value field HOT 2
- Invalid Query or Scan syntax with "single-table design" indexes HOT 1
- How can we use API resources?
- Expecting RequestInterface, given RulesetEndpoint HOT 6
- Cannot access property/attribute of returned record HOT 2
- get() with a non-existent value as the primary key using where returns a collection with null instead of an empty collection
- Laravel 11 support HOT 12
- problem in nested query HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-dynamodb.