sailsjs, using through relation, how to get the value of non related models?

拈花ヽ惹草 提交于 2019-12-05 07:26:59

问题


I have 3 models named as "User, Pet and UserPet".

User model

"user_name" : {
    type: "string",
    required: true
},
"pets" : { 
   collection: 'pet',
   via: 'user',
   through: 'userpet'
}

Pet model

"pet_name" : { 
    type: "string",
    required: true   
}

UserPet Model

user: {
    model: 'user'
},

pet: {
    model: 'pet'
},

user_expected_price: {
  type: "float",
  required: true
}

Query used to retrieve the data

User.find().populateAll().exec(function (err, data) { 
   console.log(data);
})

I can get all the data from above mentioned models except user_expected_price in userpet model because this field is not related with any model. I need this field value along with other response. Any body help me ? Sails document doesn't help me!!!

来源:https://stackoverflow.com/questions/37608302/sailsjs-using-through-relation-how-to-get-the-value-of-non-related-models

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!