Last active
June 23, 2017 23:03
-
-
Save suissa/4007599c8c76aa7571859c9ba2359568 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fn = ( f, key ) => ( e ) => ( e ) ? f( e ) : f( key ) | |
const getKey = ( database, table, userUID, child ) => | |
database.ref( table ) | |
.child( userUID ) | |
.child( child ) | |
.push() | |
const create = ( userUID, customerObj ) => { | |
return new Promise( ( resolve, reject ) => | |
getKey( database, 'user_data', userUID ) | |
.key | |
.set( customerObj ) | |
.then( fn(resolve, ref.key) ) | |
.catch( fn(reject) ) ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment