I'm, trying to make a call from my backend where I think I have to use Select MAX(column_name + 1) so that I will have a new value at that column and then show/display it the same time in my front-end.
( I will have to use it to generate a new Order Number )
But the problem is, whenever I call it in my browser to check my output it is not defined. Even in Postman.
I use Node.JS, Express-Generator and React Native
Here is my code
OrderNo.js (models)
var db=require('../dbconnection');
var Task = {
getTaskById:function(callback){
return db.query("Select MAX(order_no + 1) from orders",callback,result);
},
}
module.exports=Task;
OrderNo.js (routes)
var express = require('express');
var router = express.Router();
var Task = require('../models/OrderNo')
router.get('/order_no', (req, res, next) => {
if(req.params){
Task.getTaskById(req.params,function(err,rows){
if(err)
{
res.json(err);
}
else{
res.json(rows);
}
});
}
});
module.exports = router;
The errors:
Your result
variable in return db.query("Select MAX(order_no + 1) from orders",callback,result);
is not defined in that file. What you're seeing in a javascript execution error as the interpreter fails to find the undefined variable "result", not a MySQL error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.