const saveUser = user => { return firebase.database().ref(`/users/${user.uid}`).update({ displayName: user.displayName || '', photoURL: user.photoURL || '', uid: user.uid, }); }
constructor(props) { super(props); this.notificationsRef = firebase.database().ref(`users/${this.props.userID}/notifications`); this.state = { playSound: false } }
const fetchPlaces = (regionId) => { return database.ref(apiUris.places) .orderByChild('regionId') .equalTo(parseInt(regionId)) .once('value') .then((snapshot) => { return snapshot.val() || []; }) }
const getTrendingWishes = () => { let now = new Date(); now.setDate(now.getDate() - 3); let daysAgo = now.getTime(); return firebase.database().ref('/wishes/').orderByChild('createdAt').startAt(daysAgo); }
const startEditExpense = (id, updates) => { return (dispatch, getState) => { const uid = getState().auth.uid; return database.ref(`users/${uid}/expenses/${id}`).update(updates) .then(() => { dispatch(editExpense(id,updates)); }); }; }
//Change text data on database changeTextRef(){ const sayingRef = firebase.database().ref().child('react').child('saying'); sayingRef.set(this.inputId.value); }
questSubmit(e) { firebase.database().ref('uSurvey/' + this.state.uid).set( { studentName: this.state.studentName, answers: this.state.answers } ) this.setState({ isSubmitted: true }); e.preventDefault(); }
changeVideoBtn2(){ firebase.database().ref().child('react').child('videoID').child('vid2').once('value').then(snap =>{ this.setState({ videoID: snap.val() }); }) }
export function addComment(param) { return function (dispatch) { let path = "/Comments/" + param.title; firebase.database().ref(path).push(param.comment) } }
const deleteWish = (wishId, userId) => { let updates = {}; updates[`/wishes/${wishId}`] = null; updates[`/users/${userId}/wishes/${wishId}`] = null; return firebase.database().ref().update(updates); }
const startRemoveExpense = ({ id } = {}) => { return (dispatch, getState) => { const uid = getState().auth.uid; return database.ref(`users/${uid}/expenses/${id}`).remove().then(() => { dispatch(removeExpense({ id })); }); }; }
const upwish = (wishId, authorUid, uid) => { let updates = {}; updates[`/wishes/${wishId}/upwishes/${uid}`] = true; updates[`/users/${authorUid}/wishes/${wishId}/upwishes/${uid}`] = true; return firebase.database().ref().update(updates); }
const startRemoveExpense = ({ id } = {}) => { return (dispatch, getState) => { const uid = getState().auth.uid; return database.ref(`users/${uid}/expenses/${id}`).remove() .then(() => { dispatch(removeExpense({ id })); }); }; }