diff --git a/server.js b/server.js index 34523cf..10b756c 100644 --- a/server.js +++ b/server.js @@ -18,7 +18,14 @@ var db = new sqlite3.Database(file); db.serialize(function() { if(!exists) { - db.run("CREATE TABLE Alerts (OrigJSON TEXT)"); + db.run( + "CREATE TABLE Alerts (" + + "origJSON TEXT," + + "coreId TEXT," + + "locationDesc TEXT," + + "status TEXT," + + "published_at TEXT)" + ); } }); @@ -33,11 +40,15 @@ app.get('/', function(req, res){ app.post('/', function(req, res){ var postEvent = req.body.postEvent; var source = req.body.source; - console.log("Post event = "+postEvent+", source is "+source); + //console.log("Post event = "+postEvent+", source is "+source); console.log(req.body); - var stmt = db.prepare("INSERT INTO Alerts (OrigJSON) VALUES (?)"); - stmt.run(JSON.stringify(req.body, null, 4)); + var stmt = db.prepare("INSERT INTO Alerts (OrigJSON, coreid, published_at) VALUES (?, ?, ?)"); + stmt.run( + JSON.stringify(req.body, null, 4), + JSON.stringify(req.body.coreid, null, 4), + JSON.stringify(req.body.published_at, null, 4) + ); stmt.finalize(); //res.send(JSON.stringify(req.body, null, 4)); });