【发布时间】:2020-12-22 21:41:06
【问题描述】:
我正在尝试根据用户类型过滤用户看到的内容。我在数据库中有 3 种用户类型作为选项。目前,我有一个数组过滤掉除“国家联络代表”以外的所有内容。虽然我还需要它来过滤这个所谓的“国家”表中的孩子。基于关联的用户国家。我不确定这是否是最佳选择,或者是否有办法编写 mySQL 脚本并在后端执行。我对所有建议问题或 cmets 持开放态度。
console.log(reportingJSONObject);
// Loop on directorates
for (var i = 0; i < reportingJSONObject.tree.length; i++) {
// if isNLR, and not national liason rep skip
//hr_directory has an associated nation connected by nation
var directorateObject = reportingJSONObject.tree[i];
// var userNation = response.data.nation
if (is_nlr=true) {
console.log("isNLR");
if (directorateObject.name != "National Liaison Representative")
{
console.log("skipping entry " + directorateObject.name);
continue;
}
// gets rid of directorate entirely
// if (directorate = directorateObject.name) {
// continue;
// }
//
// if (currentVue.nation = userNation) {
// continue;
// }
};
【问题讨论】:
标签: javascript mysql arrays filtering user-permissions