My rest api calls Put request to this function to create firebase token on Postgre-sql.
 However, I realized whenever the token gets refreshed a new row will be added for the same user. 
How do I make it so that it'll perform a insert if it exists and updates if it doesn't.
 I've already tried on conflict update, but it doesn't work.
The code is here :
function createUserToken(req, res, next) {
  var userid = req.user.email;
  db.none('insert into fcmdb(userid, token)'+
    'values($1, $2) on conflict update',
    [userid,req.body.token])
    .then(function () {
      res.status(200)
        .json({
          status: 'success',
          message: 'Inserted token'
        });
    })
    .catch(function (err) {
      return next(err);
    });
}
 
     
    