When running any kind of query with sequelize I'm getting the error mentioned in the title.
This is my code for querying the data
let [userData, created] = await client.databases.userDB.findOrCreate({
where: {
robloxId
},
defaults: {
robloxId,
mnriPoints: amount,
msdPoints: 0,
mhctPoints: 0,
permLevel: 0,
createdAt: new Date(),
updatedAt: new Date()
}
})
I've tried deleting both createdAt and updatedAt, as well as changing the value to new Date().toSting(), new Date().toDateString() etc., but it all yields the same error
When googling the error all I found was this question, which didn't answer my question
Additionally I'm using sqlite
Here's the full error: Error
CodePudding user response:
As already mentioned in this question in case of SQLite you need to pass a date as a string and moreover it should a a date string in ISO format. So you can use toISOString
method of Date object to get the ISO date string:
const currISODate = new Date().toISOString();
...
defaults: {
robloxId,
mnriPoints: amount,
msdPoints: 0,
mhctPoints: 0,
permLevel: 0,
createdAt: currISODate,
updatedAt: currISODate
}