Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get("/addword", function(req, res) {
- res.render("addword");
- });
- app.post("/addword", function(req, res){
- var newWord = new Dicword ({
- word: req.body.wordInput,
- definition: req.body.defInput,
- title: req.body.titleInput,
- genre: req.body.genreInput,
- example: req.body.exInput
- });
- Dicword.exists({word: req.body.wordInput}, (function(err, existingDoc){
- if (existingDoc === null) {
- newWord.save(function(err){
- if (!err){
- console.log("add succ");
- res.render("addwordSUCC");
- }
- else {console.log(err);}
- });
- } else {
- let exists = "This word already exists"
- res.render("addwordFAIL", {exists: exists});
- }
- }));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement