[QUESTION]TypeMismatch: Expected xxx to be of type object, instead found type object
See original GitHub issueHey guys I am pretty new to DynamoDB and dynamoose, trying to migrate my mongoose code/db to dynamoose/dynamodb. I am having this exception while trying to save custom object- “TypeMismatch: Expected name to be of type object, instead found type object”. Here is my sample code on nodejs/typescript-
export = {
run: async() => {
dynamoose.aws.sdk.config.update({
"accessKeyId": "AKID",
"secretAccessKey": "SECRET",
"region": "us-east-1"
});
dynamoose.aws.ddb.local();
const Man = dynamoose.model('Man', {
id: String,
name: {
type: Object,
schema: {
firstname: String,
lastname: String
}
}});
Man.create({
id:"random",
name: new Name("John", "Martin")
});
}
}.run();
class Name {
firstname: string;
lastname: string;
constructor(firstname: string, lastname: string){
this.firstname = firstname;
this.lastname = lastname;
}
}
Can you help me with this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Dynamoose- error while saving custom type using object ...
TypeMismatch: Expected name to be of type object, instead found type object. Here is my sample code on nodejs / typescript:
Read more >Untitled
... yearly https://www.experts-exchange.com/questions/27377241/Object-doesn't- ... Values'-of-report-parameters-'MyField'-doesnt-have-the-expected-type.html ...
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@albertoantunes This is the expected behavior. You can’t store instances of classes in Dynamoose. You have to convert it to a plain JSON object.
Hey @fishcharlie I actually have the same issue but under a different schema type:
with documentation example from here
this is the error I get for reference:
I suspect the issue is at this path
dynamoose/dist/utils/dynamoose/getValueTypeCheckResult.js
but i am struggling to figure out the logic in that file.I would love a workaround if this is a bigger issue?
Thanks for the awesome library!