View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

sails.config.globals

Configuration for the global variables that Sails exposes to its Node process. The options are conventionally specified in the config/globals.js configuration file.

Properties

Property Type Default Details
sails true Expose the sails instance representing your app. If this is disabled, you can still get access via req._sails.
models true Expose each of your app's models as global variables (using their "globalId"). E.g. a model defined in api/models/User.js would have a globalId of User by default. If this is disabled, you can still access your models via sails.models.*.
services true Expose each of your app's services as global variables (using their "globalId"). E.g. a service defined in api/services/NaturalLanguage.js would have a globalId of NaturalLanguage by default. If this is disabled, you can still access your services via sails.services.*.
_ true Expose the lodash installed in Sails core as a global variable. If this is disabled, like any other node module you can always run npm install lodash --save, then var _ = require('lodash') at the top of any file.
async true Expose the async installed in Sails core as a global variable. If this is disabled, like any other node module you can always run npm install async --save, then var async = require('async') at the top of any file.

Notes

  • To disable all global variables, you can set sails.config.globals to false.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book