i want to know if there is way to create something like an After insert trigger or an asynchronous event that looks regularly through a log table and then apply the changes to another database.
i found something about the use of middlewares or the use of vanilla js functions but because of the different nommenclatures or perhaps the unclear documentation i don't think that's going to work for me. if anyone could clarify the use of post hooks on update or a promise in a function that would be great.
Basically what i want is a trigger or an event that listens to an order details table, i have 2 types of orders: current and delivered in the first type a field called deliveryDate is empty when it's updated and a value is entered in the field it should capture it and insert it in another Database.
i have a function called update that is executed everytime the route '/myApp'
gets a POST
request here is an example not far from what i want to do
here is the route:
module.exports = (app) => {
const Something= require('../controllers/something.controller.js')
// Create a new something
app.post('/Myapp', Something.update);}
here is the controller:
const Something = require('../models/something.model.js');
const SomethingLog = require('../models/something.log.model.js');
exports.update = (req, res) => {//function body}
can i create a post hook under the exports.update
function like putting the hook in a function and if i do so how will i be able to execute it should i a just assign it to the default post route wouldn't that conflict with the existing route? thank you