addition of img_url and states to local database

This commit is contained in:
Sean Clarke 2020-01-05 13:02:59 -05:00
parent a304866b11
commit 2ee5504efc
3 changed files with 9 additions and 3 deletions

View File

@ -24,6 +24,8 @@ con.connect(function(err) {
description varchar(5000),\ description varchar(5000),\
site varchar(255),\ site varchar(255),\
unesco_unique int UNIQUE,\ unesco_unique int UNIQUE,\
img_url varchar(255),\
states varchar(255),\
PRIMARY KEY (id)\ PRIMARY KEY (id)\
)", function(err, res){ )", function(err, res){
if (err) throw err; if (err) throw err;

View File

@ -20,17 +20,19 @@ val.query.row.forEach(function(site){
s.push(htmlToText.fromString(htmlToText.fromString(site.short_description), { wordwrap: false })); s.push(htmlToText.fromString(htmlToText.fromString(site.short_description), { wordwrap: false }));
s.push(site.site); s.push(site.site);
s.push(site.unique_number); s.push(site.unique_number);
// console.log(s); s.push(site.image_url);
s.push(site.states);
// console.log(site);
arr.push(s); arr.push(s);
}); });
console.log(arr); // console.log(arr);
con.connect(function(err) { con.connect(function(err) {
if (err) throw err; if (err) throw err;
console.log("Connected!"); console.log("Connected!");
sql = "INSERT INTO sites (category, in_danger, date_inscribed, unesco_url, latitude, longitude, description, site, unesco_unique) VALUES ?"; sql = "INSERT INTO sites (category, in_danger, date_inscribed, unesco_url, latitude, longitude, description, site, unesco_unique, img_url, states) VALUES ?";
con.query(sql, [arr], function(err, res){ con.query(sql, [arr], function(err, res){
if (err) throw err; if (err) throw err;

View File

@ -11,6 +11,8 @@ var Site = function(data){
this.description = data.description; this.description = data.description;
this.site = data.site; this.site = data.site;
this.unesco_unique = data.unesco_unique; this.unesco_unique = data.unesco_unique;
this.img_url = data.img_url
this.states = data.states;
}; };
// Finding the site by ID. // Finding the site by ID.