diff --git a/.gitignore b/.gitignore index 9e307b7..4f7ca54 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ .env .DS_Store -./db/posm-paths.sqlite3 +./db/* ./testData/danbjoseph .python_version .vscode diff --git a/handlers/sequence/helpers.js b/handlers/sequence/helpers.js index e3571f9..d3129ce 100644 --- a/handlers/sequence/helpers.js +++ b/handlers/sequence/helpers.js @@ -13,11 +13,12 @@ exports.insertImages = (sequence) => { }) .then(async (values) => { try { - await db.raw( - `INSERT INTO Images ( - id, path, time, seqId, userId, loc - ) VALUES ${values}` - ) + await db.raw(` + SELECT load_extension('mod_spatialite'); + INSERT INTO Images ( + id, path, time, seqId, userId, GeomFromText('POINT(${loc.lat} ${loc.lon})') + ) VALUES ${values} + `) } catch (e) { throw e; } @@ -38,11 +39,11 @@ exports.insertSequence = (sequence) => { Promise.map(sequence, image => { return { id : image.id, loc: image.loc }}) .then(async (sequenceImages) => { try { - await db.raw( - `INSERT INTO Sequences ( + await db.raw(` + INSERT INTO Sequences ( id, userId, images - ) VALUES (${sequenceId}, ${userId}, JSON(${sequenceImages})` - ) + ) VALUES (${sequenceId}, ${userId}, JSON(${sequenceImages}) + `) } catch (e) { throw e; } diff --git a/handlers/sequence/post.js b/handlers/sequence/post.js index 1e3a4bf..ee810c1 100644 --- a/handlers/sequence/post.js +++ b/handlers/sequence/post.js @@ -4,8 +4,8 @@ const Boom = require('boom'); const db = require('../../connection'); const uuidv4 = require('uuid/v4'); const buildSequences = require('../../adapters/sequence'); -// const insertImages = require('./helpers').insertImages; -// const insertSequence = require('./helpers').insertSequence; +const insertImages = require('./helpers').insertImages; +const insertSequence = require('./helpers').insertSequence; module.exports = async (r, h) => { try {