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
camelCase vs lowercase Services and Models on the Sails global object #2869
Comments
Not a bug, but maybe not well documented. The whole model name on the |
I noticed this yesterday as well when trying to re-order response objects the way they're defined in the model attributes after they come back jumbled after doing a find().populate(). A different issue that, but accessing the sails model attributes is all lowercase. If anyone is interested in knowing now to reference the attributes defined in a model, it can be referenced like this:
|
Simply
I'm not sure what "jumbling" you're referring to, since there's no such thing as the "order" of keys in JSON: RFC-4627
|
Strange... for what I'm doing As for the "jumbling" of data, basically I'm using just the keys of the model attributes to map the JSON response how I expect it to be formatted based on the order of the schema and model definitions. I understand objects can't be "sorted" but I also don't want all of the populated associated data to always come first in the response object. If anything, I'd be happy if it came last because it can be large arrays of associated data. It doesn't matter from a code standpoint to reference the object wherever the data is placed, but it is rather annoying to look at while developing, debugging and documenting your JSON responses when your main data is pushed below your associated data. Anyway, it's kind of a hack but this works to return the results in the order that I've already defined in my schema and attributes and have come to expect my results to look like. This could also just be a waterline issue. Here's a simplified version of what I'm doing...
"jumbled" result object from normal find().populate()... notice the categories and variants arrays are pushed to the top, these are populated associations.
"sorted" result object the way the model is defined, categories and variants are towards the bottom where they belong
|
Strange; would you mind opening a new issue for that? |
What's the update here? Is there a new issue? Can we close this up? |
Thanks for posting, @randallmeeker. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
In the global name space Models and Services will retain their cameCase name. On the sails object they are lower case.
Bug?? Or No Bug?
The text was updated successfully, but these errors were encountered: