1

Adding primary key to reviews

This commit is contained in:
Alex Yatskov 2014-10-17 17:59:26 +09:00
parent 3d9a4cc2ef
commit ad2f02e3af
2 changed files with 10 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -15,11 +15,11 @@ var conn = mysql.createConnection({
// //
conn.query('DROP TABLE IF EXISTS reviews'); conn.query('DROP TABLE IF EXISTS reviews');
conn.query('CREATE TABLE reviews(name VARCHAR(100) NOT NULL, url VARCHAR(200) NOT NULL, food FLOAT NOT NULL, service FLOAT NOT NULL, value FLOAT NOT NULL, atmosphere FLOAT NOT NULL)'); conn.query('CREATE TABLE reviews(name VARCHAR(100) NOT NULL, url VARCHAR(200) NOT NULL, food FLOAT NOT NULL, service FLOAT NOT NULL, value FLOAT NOT NULL, atmosphere FLOAT NOT NULL, id INT NOT NULL AUTO_INCREMENT PRIMARY KEY)');
for (var i = 0, count = data.length; i < count; ++i) { for (var i = 0, count = data.length; i < count; ++i) {
var record = data[i]; var record = data[i];
conn.query('INSERT INTO reviews VALUES(?, ?, ?, ?, ?, ?)', [ conn.query('INSERT INTO reviews(name, url, food, service, value, atmosphere) VALUES(?, ?, ?, ?, ?, ?)', [
record.name, record.name,
record.relativeUrl, record.relativeUrl,
record.rating.food, record.rating.food,