node.js - How to get Mysql DB values to a json array in node js -


how mysql db values json array in node js, can tell me steps follow achieve this

as you're beginner, here steps need perform:

  1. you need add dependency mysql project (e.g. knex js).
  2. then, can use select() promise access rows in this gist. more clear:

    return knex('books').select(knex.raw("data->'author' author"))   .whereraw("data->'author'->>'first_name'=? ",[books[0].author.first_name])   .then(function(rows) {       // here have access rows array of objects       // can stringify       console.log("found "+rows.length+        " books authors first_name "+        books[0].author.first_name);       rows.foreach(function(row){         console.log(row);      });   }) 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -