db.once('value',function(snap){ snap.forEach(function(childsnap){ var key = childsnap.key; var ref = db.child(key); ref.update({ "images" : "Yayyy" }); }); });
componentWillReceiveProps(nextProps) { if (nextProps.user.uid) { const userNotesRef = firebaseApp.database().ref(`users/${nextProps.user.uid}/notes`); // uses the firebase .on() function to listen for changes at the reference (path) defined above userNotesRef.on('value', snap => { let userNotes = []; console.log("snap", snap.val()); snap.forEach(userNote => { const { note } = userNote.val(); userNotes.push({ note: note }); }) this.setState({userNotes: userNotes}) }) } }
componentDidMount() { goalRef.on('value', snap => { let goals = []; snap.forEach(goal => { const { email, title } = goal.val(); const serverKey = goal.key; goals.push({ email, title, serverKey }); }) this.props.setGoals(goals); }) }
const getImagesFromFirebase = () => { return new Promise((resolve, reject) => { // Get a reference to the database service var database = firebase.database(); let a = []; database.ref('assets').once('value', (snapshot) => { snapshot.forEach((childSnapshot) => { a.push({ id: childSnapshot.key, ...childSnapshot.val() }) }); resolve(a) }); }) }
const startSetExpenses = () => { return (dispatch, getState) => { const uid = getState().auth.uid; return database.ref(`users/${uid}/expenses`).once('value').then((snapshot) => { const expenses = []; snapshot.forEach((childSnapshot) => { expenses.push({ id: childSnapshot.key, ...childSnapshot.val() }); }); dispatch(setExpenses(expenses)); }); }; }
listenRooms() { this.roomRef.on('value', rooms => { const items = [] rooms.forEach((child) => { items.push({ name: child.val().name, owner: child.val().owner, ownerId: child.val().ownerId, creationDate: child.val().creationDate, _key: child.key }) }) this.setState({ rooms: items.reverse(), isLoaded: true, }) }) }
snapshot.forEach((childSnapshot) => { rooms.push({ ...childSnapshot.val()
componentDidMount() { goalRef.on('value',snap => { let goals = []; snap.forEach(goal => { const {email,title}= goal.val(); goals.push({email,title}); }) this.props.setGoals(goals); }) }
export function syncFirebase(store) { var child = itemsRef.child('e5d65252-21c8-4030-951f-8a441d886740'); child.on('value', (snapshot) => { var items = []; snapshot.forEach((child) => { items.push({ title: child.val().title, message: child.val().message, date: child.val().date, _id: child.val().id }); }); store.dispatch(addItemSuccess(items)); }); connectedRef.on('value', snap => { if (snap.val() === true) { store.dispatch(goOnline()); } else { store.dispatch(goOffline()); } }); }
componentDidMount() { this.messagesRef.on('value', messages => { var items = []; messages.forEach((child) => { items.push({ userName: child.val().userName, userId: child.val().userId, userAvatar: child.val().userAvatar, message: child.val().message, creationDate: child.val().creationDate, data: child.val().data, type: child.val().type, _key: child.key }); }); this.setState({ messages: items, isLoaded: true, }) }); }
componentDidMount() { messageRef.on('value', snap => { let messages = []; snap.forEach(response => { let { message, author } = response.val(); messages.push({ message, author }); }) this.setState({messages: messages}); }) }
componentDidMount(){ completeGoalRef.on('value', snap =>{ let completeGoals = []; snap.forEach(completeGoal => { const { email, title } = completeGoal.val(); completeGoals.push({email, title}) }) this.props.setCompleted(completeGoals); }) }