Extending User schema


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?


It’s not intended but we can give it a try :slight_smile:

How does your existing schema look like?

Disclaimer: I’m not a MongoDb expert at all :smiley:


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.


Sorry, didn’t have the time to dive deeper into it yet.


So you mean instead of something like this:

   userId: 'id',
   userData: {
       data: {
             answeredQuesttions: ['a', 'b', 'c']

you have

   userId: 'id',
 answeredQuesttions: ['a', 'b', 'c']



Yes, there are other fields too of course, but this is one of them.


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.


In that case I’ll figure something out. Thank you for looking into it.