balderdashy / balderdashy/sails
defaultsTo as a function not allowed anymore in v1
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
**Sails version**: 1.0.2
**Node version**: 8.4.0
**NPM version**: 5.7.1
**DB adapter name**: N/A
**DB adapter version**: N/A
**Operating system**: CentOS 7
**Expected behaviour**
In sails.js 0.12, a function could be used for the defaultsTo attribute, for example, if you want to default to a string of the current date with the moment.js library (defaultsTo: () => moment().toISOString()).
**Actual behaviour**
This no longer works. It errors indicating an inconsistency with the specified input type and the defaultsTo type. Using moment() or new Date() as a non-function does not work; it defaults to the date in which the action/modal was loaded, rather than the date the action/modal was called. A function is necessary to default to the current date. But it will not allow that.
Contributor guide
Research direction
Start by reproducing the reported defaultsTo behavior in Sails 1.0.2 with a function returning the current date, then compare it with the Sails 0.12 behavior described in the issue. Done means function-valued defaultsTo is accepted and evaluated when the action or model is called rather than when it is loaded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100