I want to add a new object to a table using Objection.js and knex.js. I wrote this code:
const Provider = require('../models/provider);
Provider
.query()
.where('ProviderName', name)
.then((data) => {
if (data.length === 0) {
Provider
.query()
.insert({ ProviderName: name,
ProviderWebSite: webSite,
ProviderContact: contact,
ProviderStatus: status })
.then(() => {
res.render('results', { result: req.body });
});
} else {
res.render('results1');
}
})
.catch(() => {
res.render('404');
});
The problem that the page still reload and I didn't get the page results
and the table still empty.