balderdashy / balderdashy/sails
Methods in REST Response
- Dominant language
- JavaScript
- Stars
- 22.8k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
Sails version: v1.0
Node version: v8.9.1
NPM version: v6.1.0
DB adapter name: sails-mongo
DB adapter version: don't know
Operating system: macOS
Hi, how are u?
I need to run a model method and add in response from Blueprint Actions!
For example, i have the following model:
module.exports = {
attributes: {
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
tournamentStage: { type: 'number' },
matchTime: {
type: 'ref',
columnType: 'datetime',
required: true
},
//percentRealMeat: { type: 'number', defaultsTo: 20, columnType: 'FLOAT' },
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
// Add a reference to Teams
/*players: {
collection: 'team',
via: 'matchs'
},*/
localTeam: {
model: 'team',
},
visitorTeam: {
model: 'team',
},
localScorePrediction: function () {
let myPrediction = 0
/* CODE TO FIND MY PREDICTION */
return myPrediction;
},
customToJSON: function () {
console.log('hi, im hereee');
return _.omit(this, [])
},
},
};
And when i request i don't see the "localScorePrediction" value:
[
{
"createdAt": 1528080341248,
"updatedAt": 1528080341248,
"id": "5b14a7d503d4de23a69b3b82",
"tournamentStage": 0,
"matchTime": "2018-06-14:00:00.000Z",
"localTeam": {
"createdAt": 1528030218249,
"updatedAt": 1528030218249,
"id": "5b13e40a13cc3c0a94d170f7",
"name": "Rusia",
"img": "https://ssl.gstatic.com/onebox/media/sports/logos/5Y6kOqiOIv2C1sP9C_BWtA_48x48.png"
},
"visitorTeam": {
"createdAt": 1528030219436,
"updatedAt": 1528030219436,
"id": "5b13e40b13cc3c0a94d170f8",
"name": "Arabia Saudita",
"img": "https://ssl.gstatic.com/onebox/media/sports/logos/QoAJxO46fHid3_T-7nRZ0Q_48x48.png"
}
},
Any ideas?
Thanks!
Contributor guide
Research direction
Start with the model definition shown in the issue, especially localScorePrediction and customToJSON, and trace how the Blueprint Action builds its REST response. Verify the behavior with the displayed model and request; done means the returned records include the requested method value or the response behavior is documented as unsupported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100