Open tlhunter opened 5 years ago
Hi @tlhunter, Thank you for the heads up on the need for clarification. We do mention that the models are global here but I see that some further explanation on the 'using-models' page would be helpful! Thanks again!
Hi @tlhunter, Just wanted to let you know we are currently consolidating all Sails issues into one repo. ~Cheers!
Here are some of the places in the docs where we talk about globals: https://sailsjs.com/documentation/concepts/models-and-orm/model-settings#?globalid https://sailsjs.com/documentation/concepts/globals https://sailsjs.com/documentation/concepts/globals/disabling-globals
There's a rather large shortcoming in this document: https://github.com/balderdashy/sails-docs/blob/master/concepts/ORM/Models.md#using-models
In the section entitled "Using Models", there is no discussion on how to use the model. Throughout the code examples, references to
Monkey
andPerson
are repeatedly made. However there are no references to how to access the models themselves. Where doesMonkey
actually come from? How would one access this model from elsewhere in the application, such as within a Controller?The lack of explanation almost suggests a global (similar to thesails
global) is created for each model, e.g. a global namedMonkey
, however such a global does not exist.Aah, turns out Sails does create global variables for each Model. This would make a great addition to the documentation as it's not commonly expected in Node.js apps.