diff --git a/server/db/photos.js b/server/db/photos.js index 7f49779..aa717e6 100755 --- a/server/db/photos.js +++ b/server/db/photos.js @@ -56,6 +56,7 @@ function init() { filename: Sequelize.STRING, added: Sequelize.DATE, modified: Sequelize.DATE, + updated: Sequelize.DATE, scanned: Sequelize.DATE, taken: Sequelize.DATE, width: Sequelize.INTEGER, diff --git a/server/routes/photos.js b/server/routes/photos.js index d5a10eb..0e9df0b 100755 --- a/server/routes/photos.js +++ b/server/routes/photos.js @@ -126,7 +126,7 @@ router.put("/:id", function(req, res/*, next*/) { switch (req.query.a) { case "undelete": console.log("Undeleting " + req.params.id); - return photoDB.sequelize.query("UPDATE photos SET deleted=0 WHERE id=:id", { + return photoDB.sequelize.query("UPDATE photos SET deleted=0,updated=CURRENT_TIMESTAMP WHERE id=:id", { replacements: replacements }).then(function() { return res.status(200).send(req.params.id + " updated."); @@ -210,7 +210,7 @@ router.put("/:id", function(req, res/*, next*/) { return rename(target, original); }).then(function() { return photoDB.sequelize.query("UPDATE photos SET " + - "modified=:modified,width=:width,height=:height,size=:size,scanned=CURRENT_TIMESTAMP " + + "modified=:modified,width=:width,height=:height,size=:size,updated=CURRENT_TIMESTAMP,scanned=CURRENT_TIMESTAMP " + "WHERE id=:id", { replacements: asset }); @@ -341,7 +341,7 @@ router.delete("/:id", function(req, res/*, next*/) { const photo = photos[0]; if (!req.query.permanent) { - return photoDB.sequelize.query("UPDATE photos SET deleted=1 WHERE id=:id", { + return photoDB.sequelize.query("UPDATE photos SET deleted=1,updated=CURRENT_TIMESTAMP WHERE id=:id", { replacements: replacements }).then(function() { return false; @@ -487,7 +487,6 @@ router.get("/memories/:date?", function(req, res/*, next*/) { // console.log("Cursor" + cursor.toISOString().replace(/T.*/, "")); // } - return photoDB.sequelize.query(query, { replacements: { cursor: cursor, @@ -566,7 +565,7 @@ router.get("/trash", function(req, res/*, next*/) { return photoDB.sequelize.query( "SELECT photos.*,albums.path AS path,(albums.path || photos.filename) AS filepath FROM photos " + "LEFT JOIN albums ON albums.id=photos.albumId " + - "WHERE deleted=1 ORDER BY photos.filename", { + "WHERE deleted=1 ORDER BY photos.updated", { type: photoDB.Sequelize.QueryTypes.SELECT, raw: true }).then(function(photos) { diff --git a/update-db b/update-db new file mode 100644 index 0000000..fac1943 --- /dev/null +++ b/update-db @@ -0,0 +1 @@ +echo "ALTER TABLE photos ADD COLUMN updated DATE;" | sqlite3 photos.db