Skip to content

Instantly share code, notes, and snippets.

@suissa
Last active June 23, 2017 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suissa/4007599c8c76aa7571859c9ba2359568 to your computer and use it in GitHub Desktop.
Save suissa/4007599c8c76aa7571859c9ba2359568 to your computer and use it in GitHub Desktop.
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