[BUG] TypeMismatch error when attribute is called 'model'
See original GitHub issueSummary:
When trying to create an item using a schema, dynamoose triggers a TypeMismatch error when using an attribute called ‘model’. It works fine with any other attribute name.
Code sample:
Schema
const dynamoose = require('dynamoose');
const testSchema = new dynamoose.Schema({
_id: {
type: String,
hashKey: true,
},
model: {
type: Array,
schema: [
{
type: Object,
schema: {
_id: String,
text: String,
},
},
],
}
}, { saveUnkown: true, create:true }
);
module.exports = dynamoose.model('ModelTest', testSchema);
Model
// Code here
General
index.js
const dynamoose = require('dynamoose');
const Model = require('./model')
const { sdk } = dynamoose.aws;
sdk.config.update({
region: 'fake',
});
dynamoose.aws.ddb.local('http://localhost:8001');
async function runTest() {
try {
const newModel = await Model.create(
{
_id: '123',
model: [
{ _id: '12345678', text: 'someText' }
]
}
);
console.log(newModel);
} catch(err){
console.log(err)
}
}
runTest();
Current output and behavior (including stack trace):
TypeMismatch: Expected model to be of type array, instead found type object. at checkTypeFunction (…\node_modules\dynamoose\lib\Document.ts:302:11) at Array.map (<anonymous>) at Function.<anonymous> (…\node_modules\dynamoose\lib\Document.ts:323:111) at Generator.next (<anonymous>) at fulfilled (…\node_modules\dynamoose\dist\Document.js:5:58)
Expected output and behavior:
Output behavior when using the attribute as ‘model1’
Document {
_id: '123',
model1: [ { _id: '12345678', text: 'someText' } ]
}
Environment:
Operating System: Windows
Operating System Version: Windows 10 Enterprise
Node.js version (v12.18.2
):
NPM version: (6.14.5
):
Dynamoose version: 2.3.0
Other information (if applicable):
Other:
- I have read through the Dynamoose documentation before posting this issue
- I have searched through the GitHub issues (including closed issues) and pull requests to ensure this issue has not already been raised before
- I have searched the internet and Stack Overflow to ensure this issue hasn’t been raised or answered before
- I have tested the code provided and am confident it doesn’t work as intended
- I have filled out all fields above
- I am running the latest version of Dynamoose
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:13 (4 by maintainers)
Top Results From Across the Web
VBA Type Mismatch Error - The Ultimate Guide
A VBA Type Mismatch Error occurs when you try to assign a value between two different variable types. The error appears as “run-time...
Read more >Type mismatch (Error 13) | Microsoft Learn
Cause: An object was passed to a procedure that is expecting a single property or value. Solution: Pass the appropriate single property or...
Read more >Type mismatch, when passing arugment to Model Class
I have fixed the type-mismatch error by making model class variable as nullable. But I couldn't understand the error shown by the compiler....
Read more >VBA Type Mismatch Error (Error 13) - Excel Champs
Type Mismatch (Error 13) occurs when you try to specify a value to a variable that doesn't match with its data type. In...
Read more >VBA - Type Mismatch (Run-time Error 13) - Automate Excel
This will prevent the user inserting rows, and entering unexpected data. Mismatch Error Caused by Calling a Function or Sub Routine Using ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
@gmaragao I don’t see this being addressed anytime soon. This will require a strong line by line assessment of the project to determine what we need to do here. I don’t think this will happen anytime soon.
If you would like to attempt to put up a PR for this, that’d be awesome.
I’m actually using
$ADD
from the Docs to add String Set And while I’m trying to pass Array or String, it throw aTypeMismatch: Expected likedMe to be of type string set, instead found type object.
Reference to discussion opened #1512