How to use the firebase.ServerValue function in firebase

To help you get started, we’ve selected a few firebase examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prescottprue / fireadmin / src / utils / auth.js View on Github external
return userRef.once('value').then(userSnap => {
          if (userSnap.val() || userSnap.hasChild('sessions')) {
            console.error('User account already exists.')
            return Promise.reject(userSnap.val())
          }
          userObj.createdAt = Firebase.ServerValue.TIMESTAMP
          // [TODO] Add check for email before using it as priority
          return userRef.setWithPriority(userObj, email).then(_ => userObj)
        })
      })
github tivac / crucible / src / lib / firebase.js View on Github external
import Firebase from "firebase";
import config from "../config";

var firebase = new Firebase(config.firebase);

firebase.TIMESTAMP = Firebase.ServerValue.TIMESTAMP;

// For debugging
window.firebase = firebase;

export default firebase;
github steida / songary / src / client / firebase / create.js View on Github external
export default function create(firebaseUrl) {
  const firebase = new Firebase(firebaseUrl);

  return {

    TIMESTAMP: Firebase.ServerValue.TIMESTAMP,

    root: firebase,

    // const options = {
    //   scope: {
    //     facebook: 'email,user_friends',
    //     google: 'email',
    //     twitter: '' // email must be requested ad hoc
    //   }[provider]
    // }
    authWithOAuth(provider, options) {
      return promisify(onComplete => {
        // https://www.firebase.com/docs/web/guide/user-auth.html#section-popups
        firebase.authWithOAuthPopup(provider, (error, authData) => {
          if (error && error.code === 'TRANSPORT_UNAVAILABLE') {
            firebase.authWithOAuthRedirect(provider, onComplete, options);
github yeldarby / glass-presentation-remote / local.js View on Github external
}, function(err, data) {
				if(err) console.log('s3.putObject error', err);
				firebase_root.child('screencast/last_updated').set(Firebase.ServerValue.TIMESTAMP);
			});
		});
github holic / firebase-webhooks / dashboard / views / login / index.js View on Github external
firebase.authWithOAuthPopup('github', function (err, auth) {
				if (err) {
					console.log('Login failed:', err)
					alert('Login failed.\n\n' + err.message)
				}

				if (auth) {
					firebase.child('users').child(auth.uid).update({
						updated_at: Firebase.ServerValue.TIMESTAMP,
						last_auth: auth
					})
				}
			})
		}
github angular / angularjs.org / misc / resetFirebaseProject.js View on Github external
return new Promise(function(resolve, reject) {
    var date = new Date();
    var fmtDate =
      date.getFullYear() + '-' +
      doubleDigitDate(date.getMonth() + 1) + '-' +
      doubleDigitDate(date.getDate()) + ' ';
    fmtDate +=
      date.getHours() + ':' +
      doubleDigitDate(date.getMinutes()) + ':' +
      doubleDigitDate(date.getSeconds());
    newMarkerKey = projects.push({timestamp: Firebase.ServerValue.TIMESTAMP, clientTime: fmtDate}, function(err) {
      if (err) return reject(err);
      resolve(projects);
    }).key();
  });
}
github prescottprue / fireadmin / src / fireadmin.js View on Github external
this.onAuth((authData) => {
          if (!authData) {
            endedRef.set(Firebase.ServerValue.TIMESTAMP);
            currentSesh.remove();
            onlineRef.remove();
          }
        });
      }
github urish / ng2-simon / src / app / model / simon-model.service.ts View on Github external
publishScore(score: ISimonScoreInfo) {
    this.fbRef.child('games').push(Object.assign({
      date: Firebase.ServerValue.TIMESTAMP
    }, score));
  }
}
github firebase / functions-samples / fulltext-search / index.js View on Github external
index.saveObject(firebaseObject).then(function() {
      ref.child('last_index').set(Firebase.ServerValue.TIMESTAMP).then(context.done);
    }).catch(context.done);
  });
github HotSauceJS / FireText / app.js View on Github external
getUserByPhone(from, function(user){
            if (!user) return;

            var newMessage = {}
            newMessage.message = message;
            newMessage.name = user.name;
            newMessage.userId = user.id;
            newMessage.type = "default";
            newMessage.timestamp = Firebase.ServerValue.TIMESTAMP;

            var newMessageRef = roomRef.push();
            newMessageRef.setWithPriority(newMessage, Firebase.ServerValue.TIMESTAMP);
        });
    });