balderdashy / sails

Realtime MVC Framework for Node.js
https://sailsjs.com
MIT License
22.83k stars 1.95k forks source link

Shortcomings in the Models documentation #4687

Open tlhunter opened 5 years ago

tlhunter commented 5 years ago

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 and Person are repeatedly made. However there are no references to how to access the models themselves. Where does Monkey 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 the sails global) is created for each model, e.g. a global named Monkey, 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.

raqem commented 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!

raqem commented 5 years ago

Hi @tlhunter, Just wanted to let you know we are currently consolidating all Sails issues into one repo. ~Cheers!

rachaelshaw commented 5 years ago

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