Solve – cors problem

app.use(function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");

app.get('/', function(req, res, next) {
  // ....
});'/', function(req, res, next) {
 // ....

basic sql query

Today we learned how to connect to sql using work bench and command line mysql client. We created a simple table, and inserted a row.

MySql change part of the field or column

If you have a table with column that contains eg file names with extension and want to replace the extension of all those file names.

Eg we have a table named menu with column icon. The icon column contains image file names with extension .png eg dress.png , shoes.png and we want to replace only .png by .svg leaving the filename (without extension) intact. we can use the following command in SQL:

UPDATE menus SET icon = replace(icon, RIGHT(icon, 3), ‘svg’)
WHERE id > 0 AND icon <> ”;