-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't serialize nested associations #7
Comments
Yes, it was made with nested associations in mind. I think you should include assoc fields explicitely (either by their names or via |
Do you have to add the field names with the association in front? For example user.id or just id? If userLocation also has an id field called id, wouldn't there be a conflict? The error i'm getting is Error: [object Object] is not a valid Sequelize model By any chance do you have an example of a scheme that shows this? |
Well, there's an example in the readme. Nested serialization should work regardless of the depth, as long as the schemes involved are set up properly. |
I think my issue has to do with having nested associations that return Arrays (one to many relationship) inside the outer models. I noticed in the example it only shows how to deal with one (.serialize) or many (.serializeMany) but not both if it's contained together in the nested layers. |
Can you provide a sample of code that doesn't work? |
I'm trying to serialise objects created using https://github.com/overlookmotel/sequelize-hierarchy It works if I manually specify in the serialiser how deep to nest the hierarchy but I was hoping that just being able to do something like
would be enough to recurse the serialisation all the way down. Alas if doesn't, it only does the first and second tiers. |
@davesag Seems like useful capability. I'll think about it. |
maybe something like
|
does this lib work with nested associations? i'm working with 2 level deep nested associations. for example models Order -> User -> UserLocation
json { order: { user: {userLocation:{ // i want data from here to be included in the json }}}
The text was updated successfully, but these errors were encountered: