How to check if one item is in the list of firebase before to save him?
In my component my code is
this.voteService.save(cpf, 'CPFS')
My service I have
saveCPF(path: string) {
return this.db.list(this.PATH + path)
.snapshotChanges()
.map(changes => {
return changes.map(c => ( {key: c.key , ...c.payload.val() } ));
})
}
here I would like to know if item CPF is in list firebase
ex:
if(firebase.list != null) {
if(firebase.list.item == item) {
console.log('item already in list')
} else {
console.log('save success')
}
} else {
console.log('not exist list')
}