import firebase from 'firebase/app' ; import 'firebase/database' ; export const fetchUserPreferences = uid => { const userPrefs = { totalWords : 5 } ; const userPrefsRef = firebase . database ( ) . ref ( `user-prefs` ) . child ( uid ) ; return userPrefsRef . once ( 'value' ) . then ( snapshot => ( snapshot . exists ? snapshot . val ( ) : userPrefs ) ) ; } ; export const updateUserPreferences = ( uid , preferences ) => { const userPrefsRef = firebase . database ( ) . ref ( 'user-prefs' ) . child ( uid ) ; return userPrefsRef . set ( preferences ) ; } ;