2012-06-09 7 views
0

저는 node.js와 mongo db를 처음 사용합니다. 내가 뭘하려고 오전하는 index.js에서 내 model.js에 주문 함수를 호출하는 것입니다하지만 난이메서드를 찾을 수 없습니다. 오류

객체의 기능 모델() 불평이하는 주문있는 방법()

경로가 없습니다 /index.js

var pics_ = models.Picture.ordered(); 

model.js 당신이 당신의 모드로 방법을 추가하려면

Picture.prototype.ordered = function() { 
var ordered = mongoose.Picture.find().sort({points:-1}).toArray() 
console.log(ordered); 
return ordered; 
}; 
+0

model.js에서 그림 개체를 내보내시겠습니까? –

+0

예. 나는 var입니다. 그림 = mongoose.model ('Picture', PictureSchema); exports.Picture = 그림; – LivingThing

답변

관련 문제