question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] TypeMismatch: Expected createdAt to be of type date, instead found type object

See original GitHub issue

Summary:

CloudWatch log image

Doc on Dynamodb image

Code sample:

Schema

const dynamoose = require("dynamoose");
const schema = new dynamoose.Schema({
    email: {
        type: String,
        hashKey: true
    },
    github: Object,
    name: String
}, {
    saveUnknown: true,
    timestamps: true
});

module.exports = dynamoose.model('User', schema);

General

const { User } = require('../db');
const user = await User.query('email').eq(email).exec();

Current output and behavior (including stack trace):

Cant query from dynamodb

Expected output and behavior:

I should be able to query from Dynamodb when I pass the pk value

Environment:

Operating System: NA - Lambda Function Operating System Version: NA Node.js version (node -v): v10.19.0 NPM version: (npm -v): 6.14.8 Dynamoose version: 2.3.0

Other:

  • [x ] I have read through the Dynamoose documentation before posting this issue
  • [x ] 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
  • [x ] 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:closed
  • Created 3 years ago
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
fishcharliecommented, Nov 22, 2020

@AllanOricil Right now I don’t have enough information to be able to reproduce this and debug it.

Just for context. I ran the following code.

(async () => {
	const dynamoose = require("dynamoose");
	dynamoose.aws.ddb.local();
	const schema = new dynamoose.Schema({
		email: {
			type: String,
			hashKey: true
		},
		github: Object,
		name: String
	}, {
		saveUnknown: true,
		timestamps: true
	});

	const User = dynamoose.model('User', schema);

	await User.create({
		"email": "test@test.com",
		"github": {
			"credentials": {
				"unknown": "unknown"
			},
			"user": {
				"unknown": "unknown"
			}
		}
	});

	console.log("Created user");

	// Not sure what the variable `email` is set to in your original code so I used `"test@test.com"`
	const user = await User.query('email').eq("test@test.com").exec();
	console.log("Query complete");
	console.log(user);
})();

And got the following result:

charliefish@Charlies-MacBook-Pro tmp2 % node index.js
Created user
Query complete
[
  Document {
    createdAt: 2020-11-22T16:23:13.519Z,
    github: { credentials: [Object], user: [Object] },
    email: 'test@test.com',
    updatedAt: 2020-11-22T16:23:13.519Z
  },
  lastKey: undefined,
  count: 1,
  queriedCount: undefined,
  timesQueried: 1,
  populate: [Function: PopulateDocuments],
  toJSON: [Function: documentToJSON]
]

From my perspective, everything is working fine. Please submit an MCVE as described in the contribution guidelines so I can debug this further.

0reactions
yoslecommented, Sep 12, 2022

I know this is a bit late. But there was no clear solution for the problem yet. So here I go: I had the same problem, same error message. I was using Local instance of DynamoDB so I deleted the tables using NoSQLWorkbench. Seems that I have made a change in the createdAt data type and it was conflicting with the previously saved schema.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expected 'property' to be of type string, instead found type object
My guess is that the problem could be related with the name of your attribute, model . In fact, this is the actual...
Read more >
Schema - Dynamoose
The keys of this Schema object represent the name of the attributes, with the value allowing for customization such as changing the storage...
Read more >
Error decoding parse-server response - ParseSwift SDK
I'm playing around with ParseSwift and a local Parse Server (4.5.0). Whenever I try to perform a query or saving an object to...
Read more >
Failed to parse field of type in document with id ''. - Opster
You will find below our request and the error message we got back and extracted from the response object. PUT test/_doc/1.
Read more >
AWS AppSync Developer Guide - Amazon S3
Now that you have an object type and can query the data, ... back to the Schema page in the AWS AppSync console...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found