not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
826 B

  1. //
  2. const mysql = require('mysql');
  3. const sanitizer = require('sanitizer');
  4. module.exports=
  5. {
  6. /**
  7. * Function used to use insert statements into the database
  8. *
  9. * Don't worry, the input gets sanitized
  10. *
  11. * @param sqlStatement
  12. * @return the id of the new record - if there is one
  13. */
  14. insert : function(sqlStatement)
  15. {
  16. return new Promise(function(resolve, reject)
  17. {
  18. con.query(sanitizer.sanitize(sqlStatement), function (err, result)
  19. {
  20. if (err)
  21. {
  22. console.log(err);
  23. resolve(0);
  24. }
  25. resolve(result.insertId);
  26. });
  27. })
  28. }
  29. };