balderdashy / balderdashy/sails

Methos in Models

Open
#4,447 2 comments 0 reactions 0 assignees View on GitHub
more info please question
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

Open the contributing guide

Research direction

Start with the model definition in the issue and the Blueprint Actions response path; no project file or test is named. Determine whether model methods are intended to be serialized into Blueprint responses, and define the expected response behavior and coverage needed before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.