Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store array values in single column in MySQL and Node.js?

Can I store array values in single column in MySQL? since I have an array and want to store in database like here is some stuff which I want to execute.

var meida_array=[];
var media_length=response.media.length;
for(var i=0;i<media_length;i++){
   var parsed = url.parse(response.media[i]['link']);
   meida_array.push(parsed.host + parsed.path)
}
for (var i = 0; i < meida_array.length; i++) {
   console.log(meida_array[i]);
}

I am getting the array but stuck in to store in database Thanks, in advance :)

like image 890
abdulbarik Avatar asked Feb 11 '23 13:02

abdulbarik


1 Answers

Use Json stringify and store in database

var stringObj = JSON.stringify(meida_array);
like image 147
jamseernj Avatar answered Feb 15 '23 10:02

jamseernj