projects
/
vchess.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add Knightrelay1. Some fixes. Move odd 'isAttackedBy_multiple_colors' to Checkered...
[vchess.git]
/
server
/
models
/
Problem.js
diff --git
a/server/models/Problem.js
b/server/models/Problem.js
index
5c9af0b
..
bcbefc5
100644
(file)
--- a/
server/models/Problem.js
+++ b/
server/models/Problem.js
@@
-33,12
+33,15
@@
const ProblemModel = {
});
},
});
},
- get
All: function(
cb) {
+ get
Next: function(cursor,
cb) {
db.serialize(function() {
const query =
"SELECT * " +
db.serialize(function() {
const query =
"SELECT * " +
- "FROM Problems";
- db.all(query, (err,problems) => {
+ "FROM Problems " +
+ "WHERE added < " + cursor + " " +
+ "ORDER BY added DESC " +
+ "LIMIT 20"; //TODO: 20 is arbitrary
+ db.all(query, (err, problems) => {
cb(err, problems);
});
});
cb(err, problems);
});
});
@@
-50,7
+53,7
@@
const ProblemModel = {
"SELECT * " +
"FROM Problems " +
"WHERE id = " + id;
"SELECT * " +
"FROM Problems " +
"WHERE id = " + id;
- db.get(query, (err,problem) => {
+ db.get(query, (err,
problem) => {
cb(err, problem);
});
});
cb(err, problem);
});
});
@@
-66,7
+69,7
@@
const ProblemModel = {
"instruction = ?," +
"solution = ? " +
"WHERE id = " + prob.id + " AND uid = " + uid;
"instruction = ?," +
"solution = ? " +
"WHERE id = " + prob.id + " AND uid = " + uid;
- db.run(query, [prob.instruction,prob.solution]);
+ db.run(query, [prob.instruction,
prob.solution]);
});
},
});
},