array.map(function(t){
var table_name = t.user_id == null/undefined ? "university" : "users";
var table_field = v.user_id == null/undefined ? "university_id" : "user_id ";
db.query('SELECT * from ' + table_name+ ' where table_field = $1', [u._id], function(err, result) {
return result.rows
})
})
如果数组中存在用户ID,则代码应将表名作为用户,将user_id作为table_field,如果没有user_id,则应将大学作为表名,将university_id作为table_field。有人请指导我。