Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs update in mysql

let mysql = require('mysql');
let config = require('./config.js');

let connection = mysql.createConnection(config);

// update statment
let sql = `UPDATE todos
           SET completed = ?
           WHERE id = ?`;

let data = [false, 1];

// execute the UPDATE statement
connection.query(sql, data, (error, results, fields) => {
  if (error){
    return console.error(error.message);
  }
  console.log('Rows affected:', results.affectedRows);
});

connection.end();
Comment

PREVIOUS NEXT
Code Example
Javascript :: lodash sort json 
Javascript :: array json 
Javascript :: metro server not running react native 
Javascript :: angular socket.io with token header 
Javascript :: A bad HTTP response code (404) was received when fetching the script. 
Javascript :: javascritp canvas 
Javascript :: how to deep copy an object in javascript 
Javascript :: state hook is not updating react 
Javascript :: javascript particles js not working 
Javascript :: match ids from 2 arrays in javascript asynchronous programming 
Javascript :: password meter 
Javascript :: how to check if a key exists in an object javascript 
Javascript :: javascript check if array 
Javascript :: what is last index of array 
Javascript :: fs.readdir callback function 
Javascript :: javascript stop each loop 
Javascript :: JavaScript Split the string into an array of characters 
Javascript :: react lazy load suspense 
Javascript :: Creating URL Search Parameters From An Array 
Javascript :: fullcalendar react add event duration 
Javascript :: usehistory hook 
Javascript :: promise.all 
Javascript :: javascript check if array is subset of another 
Javascript :: accessing via name jquery 
Javascript :: farewell discord.js 
Javascript :: javascript foreach loop 
Javascript :: next auth session callback 
Javascript :: what is redis used for 
Javascript :: react native navigation shared element 
Javascript :: regex check if number is greater than 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =