Ask coding questions

← Back to all posts
Can't set database value to class?
MaxwellGeringer

When I try to set a replit database key to a class and then get that value, it just returns an object with the values of the class's variables. After accountmanager.js line 54, if I run user.validateAccount() it works fine, but if I do it after line 69, it errors and returns TypeError: user.validateAccount is not a function in console.

Answered by RoBlockHead [earned 5 cycles]
View Answer
Voters
MaxwellGeringer
Comments
hotnewtop
RoBlockHead

At its core, replit db only stores strings, so you can’t store language-specific objects. I’d suggest storing data about users as JSON then parsing it and creating User objects from that data.