function csnotebook(){
function calculate_mw(peptide){
var total_mw=0;
var split_peptide = peptide.split("-");
// Check if the blog id is found in database
Aa.findOne({ three_letter: split_peptide[1] }, (err, aa) => {
// Check if the id is a valid ID
if (!aa) {
console.log("wrong aa");
}else{
total_mw += aa.mw;
}
return total_mw;
});
}
var publicAPI = {
mw: calculate_mw
};
return publicAPI;
}
var fred = csnotebook();
var totalmw = fred.mw("Ala-Cys");
console.log(totalmw);
我的想法是这样的, 我传进来一个氨基酸链,用“-”, 我怎么通过mongoose找名字(unique),来找对应的mw,让后累加,最后返还? 有人有注意吗? 我不太会javascript比较菜,求轻喷。。。。。。。我之前用loop里加find不能用。。。。