Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Last active December 19, 2015 09:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikermcneil/5930330 to your computer and use it in GitHub Desktop.
Save mikermcneil/5930330 to your computer and use it in GitHub Desktop.
How to try out Sails.js 0.9

Sails v0.9 Preview

Installation

# Install a sneak peek of sails.js v0.9.0 (global install):
sudo npm install -g sails@git://github.com/balderdashy/sails.git#development

# Or, to revert to 0.8.94 (current stable release), you can do:
sudo npm install -g sails@0.8.94

##################################################################################

NOTE: When making a new app with v0.9, sails copies down a version of itself into the new project directory In npm, local versions of a module dependency override the global, so to revert your new app, you'll either need to:

# (a) Force `foo` to use the global sails
cd foo && rm -rf node_modules/sails

# or (b) Replace the 0.9 preview with the stable version of sails locally in `foo`
cd foo && npm install sails@0.8.94

Migration

  • Replace calls to find() with findOne(), then replace calls to findAll() with find()

  • Upgrade async functions (forEach -> each)

  • Blueprint controller actions are now find and findOne, not findAll and find (probably a change in config/routes.js and/or config/policies.js)

  • npm install grunt --save

  • If you're using a view engine which does not support partials, you'll need to take the upgrade path from Express 3 (we have built in support for emulating behavior of Express 2.x in ejs, for convenience)

  • Validations: Databases with defined schemas are now stricter about types. You should set the type to 'text' explicitly for any big string attributes.

  • Validations: 'strict' is now on by default

  • Blueprints: The find blueprint now handles plural and singular model data- If you were overriding find to handle requests to 'GET /foo/:id', you should adapt your controller function to handle the case where no id is provided as well (return a list of models, not just one). As a corollary, findAll no longer exists-- if you were overriding it in a controller, and using the automatic routing to handle requests to 'GET /foo', you'll need to change findAll to find.

  • Sessions-- Socket.io sessions now mimic the behavior of Express-- so when you call res.send(), res.json(), or res.redirect() in a controller action with a request originating from a socket message, the session will be automatically persisted. If you were explicitly calling req.session.save(), you can continue to do that, but it won't be necessary in the general case.

  • req.params.controller, req.params.action, and req.params.entity are no longer passed down to every request. Instead, req.target contains { controller: 'foo', action: 'bar' }. req.params.id is still set if it is a path parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment