-exports.fetchN = function(vname, uid, type, directionStr, lastDt, MaxNbProblems, callback)
-{
- db.serialize(function() {
- let typeLine = "";
- if (uid > 0)
- typeLine = "AND id " + (type=="others" ? "!=" : "=") + " " + uid;
- const query =
- "SELECT * FROM Problems " +
- "WHERE vid = (SELECT id FROM Variants WHERE name = '" + vname + "') " +
- " AND added " + directionStr + " " + lastDt + " " + typeLine + " " +
- "ORDER BY added " + (directionStr=="<" ? "DESC " : "") +
- "LIMIT " + MaxNbProblems,
- db.all(query, callback);
- });
-}
+ // TODO: update fails (but insert is OK)
+ update: function(id, uid, fen, instructions, solution, cb)
+ {
+ db.serialize(function() {
+ const query =
+ "UPDATE Problems SET " +
+ "fen = '" + fen + "', " +
+ "instructions = ?, " +
+ "solution = ? " +
+ "WHERE id = " + id + " AND uid = " + uid;
+ db.run(query, [instructions,solution], cb);
+ });
+ },