RSS 피드에서 데이터를 가져와 Firebase의 데이터베이스에 구조화 된 날짜로 추가하고 있습니다. RSS 피드가 새로 고침 될 때마다 새 UID가 추가되지만 문제는 동일한 값을 추가한다는 것입니다. 즉 : Firebase 데이터베이스에서 복제본 건너 뛰기
에 값이 있는지 확인하는 방법, 예를 들어,이 있습니까 업데이트 : "Fish showing all .."이 (가) 이미 존재하며 대신 완전히 새로운 UID를 추가하지 마십시오. 구문 분석 된 피드를 사용하도록되어 이feedparser.on('readable', function() {
// This is where the action is!
var stream = this
, meta = this.meta // **NOTE** the "meta" is always available in the context of the feedparser instance
, item;
while (item = stream.read()) {
console.log(item);
var pubDate = item.pubDate;
var date = new Date(pubDate);
var description = item.description;
var parts = description.split(' - ', 2);
var time = parts[0];
var update = parts[1];
// date.setTimezone
// var time = date.getHours()+":"+date.getMinutes();
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
];
var month = monthNames[date.getMonth()]+" "+date.getDate();
var postData = {
time: time,
date: month,
update: update,
description: description,
day: pubDate
};
var newPostKey = firebase.database().ref().child('feed').push().key;
var updates = {};
updates['/feed/' + month + '/' + newPostKey] = postData;
return firebase.database().ref().update(updates);
특정 값이 고유하다는 것을 보장하려는 것 같습니다 : http://stackoverflow.com/questions/25294478/how-do-you-prevent-duplicate-user-properties-in-firebase –