get latest id
This commit is contained in:
parent
e658e13d6a
commit
cc8dc9b37e
@ -231,7 +231,7 @@ function Websrv(tlib) {
|
|||||||
var query = "select * from `f0ck`.`items`";
|
var query = "select * from `f0ck`.`items`";
|
||||||
lib.sql.query(query, (err, rows, fields) => {
|
lib.sql.query(query, (err, rows, fields) => {
|
||||||
var items = [];
|
var items = [];
|
||||||
rows.forEach((e,i,a) => {
|
rows.forEach(e => {
|
||||||
items.push({
|
items.push({
|
||||||
'id': e.id,
|
'id': e.id,
|
||||||
'mime': e.mime
|
'mime': e.mime
|
||||||
@ -241,6 +241,12 @@ function Websrv(tlib) {
|
|||||||
res.end(JSON.stringify(items), 'utf-8');
|
res.end(JSON.stringify(items), 'utf-8');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
else if(url[2] == "latest") {
|
||||||
|
lib.sql.query("select max(stamp) from `f0ck`.`items` limit 1", (err, rows) => {
|
||||||
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
||||||
|
res.end(JSON.stringify({latest: rows[0].id}), 'utf-8');
|
||||||
|
});
|
||||||
|
}
|
||||||
else if(url[2] == "p" && Number.isInteger(parseInt(url[3]))) { // pagination
|
else if(url[2] == "p" && Number.isInteger(parseInt(url[3]))) { // pagination
|
||||||
var eps = 50;
|
var eps = 50;
|
||||||
var id = url[3];
|
var id = url[3];
|
||||||
|
Loading…
Reference in New Issue
Block a user