
insert.run('Obi Wan Kenobi', "That’s no moon!" );
insert.run('The Terminator', 'Hasta la vista, child.');
insert.run("Captain Ahab", "There she blows!");
Now let’s create a technique to make new quotes. First, we’ll want an endpoint that accepts requests with the info for brand new quotes, in server.js:
app.publish('/quotes', (req, res) => {
const { quote, writer } = req.physique;
const insert = database.put together('INSERT INTO quotes (title, quote) VALUES (?, ?)');
insert.run(writer, quote);
res.redirect('/');
});
This tells Specific to simply accept requests at /quotes, then parses and destructures the request physique into two variables: quote and writer. We use these two variables in a ready assertion that inserts a brand new row into the quotes database. After that, we redirect to the homepage, the place the record of quotes (which we’ll construct in a second) can render the brand new merchandise.
Replace the views/index.pug to incorporate a type, like so:


