1
I have an api in nodejs
www:
...
db.sequelize.transaction()
.then(() => {
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
})
...
models:
'use strict';
module.exports = (sequelize, DataTypes) => {
const RCC = sequelize.define('RCC', {
RCC_RESP: DataTypes.STRING,
RCC_CCT: DataTypes.STRING,
R_E_C_N_O_:{
type: DataTypes.INTEGER,
allowNull: false, //se aceita nulo
autoIncrement: true,
primaryKey: true
},
D_E_L_E_T_: {
type: DataTypes.STRING(1),
allowNull: false, //se aceita nulo
autoIncrement: false
}
}, {});
RCC.associate = function(models) {
// associations can be defined here
};
return RCC;
};
controller:
class RCC {
async show(db) {
return await db.RCC.findAll({
where: {
RCC_CCT: '050101'
}
})
}
}
export default new RCC();
Routes:
...
routes.get('/showAll', async (req, res) => {
const show = await RESP.show(db);
if (show) {
res.status(200).send(show)
} else {
res.status(404).json({ message: 'No Data Found' });
}
})
table name (not created by api) in my bd is: RCC, only when I give a console to see how the request is going, it gives a select in the table (there is no) Rccs, this is being standard.
Is there any way to change that? instead of doing a select in the Rccs table, actually do in the RCC table?
but that’s exactly what I do
– Maria