I want to avoid duplicate pushing into my firebase. The code is like this
const itemsRef = firebase.database().ref('Titles');
console.log(itemsRef)
let poster = this.state.data.Poster
let title = this.state.data.Title
let movieTitle = {
title: title,
poster : poster,
}
itemsRef.push(movieTitle)
This is how I'm storing my data
UPDATE: I solve this by making map loop and using index of.
const pos = arr.map(function(e) { return e.title; });
if (pos.indexOf(title) === -1){
itemsRef.push(movieTitle)
} else {
console.log('Already exist')
}