지금 인턴중인데 bookshelf + knex 만져야 되는데...좋은 인터넷 강좌나 책등 좀 알려주세요
혹시라도 밑에 있는 코드좀 볼수있으면 대충 조언 던져주시면 감사하겠습니다.
밑에 nested된 부분을 없애야 되는데.. 어떻게 어떤방법으로 바꾸는게 좋아요? 앞으로 더 많은 모델들을 붙여야 돼는데 (20+ 가지 됨).
그래서 nested을 피할려고 하는데...조언좀 부탁드립니다.
getItem: function (req, res, next) {
DepartmentCollection.forge()
.fetch({
debug: true
})
.then(function(collection) {
new GlossaryTerm({'GlossaryTermID': req.params.id}).fetch({
withRelated: ['department'],
debug: true
})
.then(function(model) {
if ("undefined" === typeof collection) { console.log("step 2: variable is undefined") }
else { console.log("step 2: variable is defined") };
res.render('glossary/glossary-term-detail',{domain:'GlossaryTerm', title: 'Glossary Term Detail',
data: model, department_data: collection });
}).catch(function(error) {
console.log(error);
res.send('An error occured');
});
}).catch(function(error) {
console.log(error);
res.send('An error occured');
});
}
,
Lodash flow 를 이용해서 promise .then 코드를 없에고 함수형으로 compose 합니다
kyle님 감사합니다.