-1
我收到一個錯誤,指出:MySQL的Node.js的語法錯誤(我都快瘋了)
C:\Users\Minh Lu\Desktop\MusicMediaWebApp\database\dbService.js:34
[0] con.query(sql, typeCast: function(field, next) {
[0] ^^^^^^^^
[0]
[0] SyntaxError: missing) after argument list
從這:
/* Retrieves a User model by ID */
getUserByID: function(ID, callback) {
this.tryConnect().getConnection(function(err, con) {
var sql = queries.getUserByID;
con.query(sql, typeCast: function(field, next) {
// We only want to cast bit fields that have a single-bit in them. If the field
// has more than one bit, then we cannot assume it is supposed to be a Boolean.
if ((field.type === "BIT") && (field.length === 1)) {
var bytes = field.buffer();
// A Buffer in Node represents a collection of 8-bit unsigned integers.
// Therefore, our single "bit field" comes back as the bits '0000 0001',
// which is equivalent to the number 1.
return(bytes[ 0 ] === 1);
}
return next();
}, ID, function (err, result) {
if (err) throw err;
// Call the callback function in the caller of this method so we can do something with this "result"
return callback(result); // [] if not found
});
});
},
而且我很困惑,什麼樣的語法這是錯誤嗎?這與文檔中的方法相同:https://github.com/mysqljs/mysql#type-casting
謝謝!
是的,我意識到這一點。謝謝! –