Skip to content
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

How to nested subresource? #5

Closed
kethan opened this issue Apr 9, 2016 · 3 comments
Closed

How to nested subresource? #5

kethan opened this issue Apr 9, 2016 · 3 comments

Comments

@kethan
Copy link

kethan commented Apr 9, 2016

Can you please help me more than one sub-resource ie nested?

@artzstudio
Copy link
Collaborator

Hey there, this is currently not supported and not a current priority. Do
you think you can simplify your scheme structure for now to avoid the
nesting?

On Friday, April 8, 2016, Kethan notifications@github.com wrote:

Can you please help me more than one sub-resource ie nested?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#5

@kethan
Copy link
Author

kethan commented Apr 11, 2016

No just for understanding purpose i would like to implement it..can you please give me some hint or example how to use it?

@kethan
Copy link
Author

kethan commented Apr 13, 2016

Anyway thank you i have implemented it..

rec = function(schema) {
var fields = [];
var paths = Object.keys(schema.paths);
for (i in paths) {
var path = paths[i];
var nestedSchema = schema.paths[path].schema;
if (nestedSchema) {
var nestedFields = rec(nestedSchema);
for (i in nestedFields) {
fields.push(path + '.0.' + nestedFields[i]);
}
} else if (schema.paths[path].caster) {
fields.push(path + '.0');
} else {
fields.push(path);
}
}
var virtuals = Object.keys(schema.virtuals);
fields = _.union(fields, virtuals);
return _.without(fields, '_id', '__v');
};

Thanks to restberry.

@kethan kethan closed this as completed Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants