balderdashy / sails

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

Modifying arguments in beforeCreate lifecycle hook requires mutating arguments? #6858

Open yowzadave opened 5 years ago

yowzadave commented 5 years ago

Node version: v12.7.0 ORM hook version (sails-hook-orm): 2.1.1 Waterline version (waterline): 0.13.6 Postgres adapter version (sails-postgresql): 1.0.2


New to waterline, so I still have a lot of questions! The preferred way of using a function to set attribute defaults, if I understand correctly, is to use the beforeCreate lifecycle hook: https://github.com/balderdashy/sails/issues/4477#issuecomment-486384188

This technique involves reassigning the function parameters, which sets off my linter: https://eslint.org/docs/rules/no-param-reassign

Is there a technique for achieving this that doesn't involve mutating the arguments object?

sailsbot commented 5 years ago

@yowzadave Thanks for posting! We'll take a look as soon as possible.

In the mean time, there are a few ways you can help speed things along:

Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.

For help with questions about Sails, click here.

whichking commented 5 years ago

Hi, @yowzadave! What about creating a custom action to set your default values, and then passing those into the call to create?