View our GitHub

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

Edit Page


Default values for blueprint create and update actions.

Note: Before using req.options.value, confirm that it exists and create it if necessary.


To default to using the logged-in user’s name when creating a new record:

// In config/policies/createWithUserName.js
module.exports = function createWithUserName (req, res, next) {

  if (req.session.user) {

    // Use existing req.options.values, or initialize it to an empty object
    req.options.values = req.options.values || {};

    // Set the default `name` for "create" and "updates" blueprints =;


  return next();


Then apply this policy to the desired blueprint actions.

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.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book