async function resolveStudent(student, connection) {
  return new Promise((resolve, reject) => {
    if(student.peekabookid) {
      resolve(student.peekabookid);
    }
     else {
      //Insert into Student
      var query = 'insert into Student SET ?'; 
      var data = {
        Name: student.name,
        Contact: student.contact, 
        Department: student.dept, 
        Year: student.year, 
        Locality: student.locality
      };
      connection.query(query, data, (err, result) => {
        if(err) {
          return reject(err);
        }
        resolve(result.insertId);
      });
    }
  });
}
//Inserts student into database if PeekaBookId not known
Inserts student into database if PeekaBookId not known
Inserts student into database if PeekaBookId not known
async function resolveStudent(student, connection) {
  return new Promise((resolve, reject) => {
    if(student.peekabookid) {
      resolve(student.peekabookid);
    }
     else {
      var query = 'insert into Student SET ?'; 
      var data = {
        Name: student.name,
        Contact: student.contact, 
        Department: student.dept, 
        Year: student.year, 
        Locality: student.locality
      };
      connection.query(query, data, (err, result) => {
        if(err) {
          return reject(err);
        }
        resolve(result.insertId);
      });
    }
  });
}
async function resolveStudent ( student , connection ) { return new Promise ( ( resolve , reject ) => { if ( student . peekabookid ) { resolve ( student . peekabookid ) ; } else { var query = 'insert into Student SET ?' ; var data = { Name : student . name , Contact : student . contact , Department : student . dept , Year : student . year , Locality : student . locality } ; connection . query ( query , data , ( err , result ) => { if ( err ) { return reject ( err ) ; } resolve ( result . insertId ) ; } ) ; } } ) ; }
Inserts student into database if PeekaBookId not known
Inserts student into database if PeekaBookId not known
//Insert into Student