하나의 지속 모델의 원격 메소드에서 루프백의 다른 지속 모델의 데이터에 액세스하는 방법은 무엇입니까?
'use strict';
module.exports = function (City) {
City.GetCurrentPopulation = function (req) {
var population;
City.app.models.Pupulation.find({where{id:req.id}}, //This line //gives me an error that cannot read property 'find' of undefined
function(req.res){
population=res.population;
});
response='Population for ' +req.cname ' is' +population;
req(null, response);
};
City.remoteMethod(
'GetCurrentPopulation', {
http: {
path: '/GetCurrentPopulation',
verb: 'GetCurrentPopulation'
},
returns: {
arg: 'startdate',
type: 'string'
}
}
);
이 모델 도시이고 내가 "population.find (일부 필터)"와 같은 다른 모델에 액세스 할 방법이 작업을 수행하려면?
도시 모델로 작성된 원격 메소드가 있습니다. 인구 기록에 액세스하려고하는 곳 :
var countryp = population.find (where {id : 4});
var currentpopulation = countryp.Totalpopulation;
오류를 발생시킵니다 .find는 함수가 아닙니다.
이 방법을 제안하십시오.
설명서를 참조 할 수 있습니다 : 당신은이 같은 시도
사용하여 응용 프로그램 개체에 대한 참조를 얻을 필요가? 질문에 맞는 태그가 있는지 확인하십시오. 또한 사용중인 환경 및/또는 관련 라이브러리에 대한 정보를 추가하십시오. 그렇지 않으면 질문의 내용을 추측하기 어렵습니다. –
네, 기존의 postgresql 데이터 소스에서 API를 만들려고하는 loopback.js와 관련이 있습니다. –
코드를 게시 할 수 있습니까? – Dyo