My firebase database has two main trees: "tag" and "user". Each user is associated with a set of tags, referred to as preferences. Here is the structure of my database:
https://i.sstatic.net/m98EO.jpg
I am trying to display a list of preferences that a specific user does not have.
Example:
Tags: 1, 2, 3, 4
User has preference 1 and 3
I want to display in a list: 2 and 4!
I have successfully implemented code to show all the preferences/tags that the user has. However, I am struggling to figure out how to display a list of what the user doesn't have!
Below is the code that accurately displays the common preferences (which is currently working correctly)
showUserPreferences(){
let userTag = [];
var ref = firebase.database().ref('/users/'+ this.email+'/preferenze/')
var ref1 = firebase.database().ref('/tag/');
ref.once('value', function(preferenze){
preferenze.forEach(function(singolaPref){
ref1.once('value', function(tags){
tags.forEach(function (singoloTag){
if(singolaPref.key == singoloTag.key){
userTag.push(singolaPref.child("nome").val())
}
return false;
})
})
return false;
})
}).then(a=>{
this.tags = userTag;
})
}
I hope I have clearly explained my issue. Feel free to ask for more code or details if needed. Thank you in advance.