I am developing a web application in Node.js using the express framework and as an Oracle 10g database.
I am using the Oracle module for Node.js and a PHP example guide, I tried to emulate the example to Node but I still can not get the result of the autocomplete, for now I only display the values in the input more they do not complete the data, nor are they kept in the input, please if you could guide me for this I would be grateful.
Official OracleDB documentation for Node.js
My code is as follows ...
Node:
router.get('/list_user', authorize, function(req, res, next) {
var connect = require('../connections/conn')(2);
oracledb.getConnection(
connect,
function(err, connection) {
if (err) {
console.error(err.message);
return;
}
connection.execute("SELECT NOMBRE FROM USUARIOS", function(err, result) {
if (err) {
console.error(err.message);
} else {
var usuarios = [];
console.log("Complete...");
for (var index = 0; index < result.rows.length; index++) {
usuarios.push(result.rows[index].NOMBRE);
}
res.send(usuarios);
}
connection.close();
});
});
});
The function for autocomplete:
$(function() {
$("#vnombre").autocomplete({
source: "/usuarios/list_user",
type: "GET",
minLength: 2,
select: function(event, ui) {
event.preventDefault();
$('#vnombre').val(ui.item.NOMBRE);
}
});
});
HTML:
<div class="form-group ui-widget">
<label class="col-sm-2 col-md-2 col-lg-2 l " for="textinput">Nombre</label>
<div class="col-sm-10 col-md-10 col-lg-10">
<input type="text" placeholder="Nombre" class="form-control
mayus" id="vnombre" name="vnombre">
</div>
</div>
Example MySQL + Node.js: