I use mongoDb as persistence adapter. I already have existing User table in the database which uses different schema than the one jovo use. Is there a way to extend jovo User schema with fields that I have in existing Users table so that they get picked up when User is loaded?
Extending User schema
AlexSwe
#2
It’s not intended but we can give it a try
How does your existing schema look like?
Disclaimer: I’m not a MongoDb expert at all
Just as an example, I have ‘answeredQuestions’ array at the root of an existing user. Do you know a way, before loading user, how to inject this field to an existing jovo user schema? Data is loaded on user.load event, so I probably would need to change schema before that.
AlexSwe
#5
So you mean instead of something like this:
{
userId: 'id',
userData: {
data: {
answeredQuesttions: ['a', 'b', 'c']
}
}
you have
{
userId: 'id',
answeredQuesttions: ['a', 'b', 'c']
}
?
AlexSwe
#7
Hm, I looked into the code and I can’t find a workaround. I would recommend building a migrating script.
Something that maps answeredQuestions
to userData.data.answeredQuestions
.