Only run write value at realtime database only once

            firebase.auth().onAuthStateChanged(function(user) { 
            if (user){
firebase.database().ref("users/" + user.uid).set({
            email:user.email, 
             points:"500",
            uid: user.uid
             })
   var query = firebase.database().ref("users").child(user.uid);
        query.once("value") .then(function(snapshot) {
              var email = snapshot.val().Email;
              var point = snapshot.val().points;
         document.getElementById("points").innerHTML=point;
        });


    

The code above is for writing and retrieving the data from database
but it is not going according to plans whenever there is changes on
points it automatically restores points to 500,, is there a way where a user’s data is written only once?