: Date.now,
    },
});

module.exports = mongoose.model('Quote', Quote);

As Stated I have an Array setup to hold multiple quotes.
Here is the method for adding a quote to the mongoDB:
    let quote = new Quotes({
        name: req.body.name,
        quote: req.body,
    });
    quote
       .save()
       .then(quote => {
            res.status(200).send('adding new quote successful');
        })
       .catch(err => {
            res.status(400).send('adding new quote failed' + err);
        });
}); 

This does add a record to the DB but I am not sure if this method is best practice.
This is the update method that is NOT working at all
router.post('/update/:id', (req, res) => {
    // Quotes.findOneAndUpdate({ name: req.body.name }, { $push: { quote: req.body.quote } });
    Quotes.findById(req.params.id, function(err, quote) {
        if (!quote) {
            res.status(404).send('Data is not found');
        } else {
            quote.author = req.body.name;
            quote.quotes = { $push: { quote: req.body.quote } };
            quote.date_submitted = req.body.date_submitted;

            quote
               .save()
               .then(quote => {
                    res.json('quote updated');
                })
               .catch(err => {
                    res.status(400).send('Update not possible' +'' + err);
                });
        }
    });
});

You can see that I tried to do the findOneAndUpdate method but it did not push the values into the array like it should. When I submit my POST request from Postman I do not get an error but when I check the Database the Array value remains the same. Any help on this would be amazing!

A:

You could try pushing the quote to the quote.quote using a simple array#push, then saving the document. 
   quote.quote.push(req.body.quote)


: Date.now, 
     }, 
 }); 

 module.exports = mongoose.model('Quote', Quote); 

 As Stated I have an Array setup to hold multiple quotes. 
 Here is the method acting for lend a quote to the mongoDB: 
     let quote = newfangled Quotes ({ 
         name: req.body.name, 
         quotation: req.body, 
     }); 
     quote 
        .save () 
        .then(quote = > { 
             res.status(200).send('adding new quote successful'); 
         }) 
        .catch(err = > { 
             res.status(400).send('adding modern quote fail' + err); 
         }); 
 }); 

 This does add a record to the DB but I am not sure if this method is good practice. 
 This is the update method acting that is NOT working at all 
 router.post('/update/:id', (req, res) = > { 
     // Quotes.findOneAndUpdate ({ name: req.body.name }, { $ push: { quote: req.body.quote } }); 
     Quotes.findById(req.params.id, function(err, quote) { 
         if (! quote) { 
             res.status(404).send('Data is not found'); 
         } else { 
             quote.author = req.body.name; 
             quote.quotes = { $ push: { quote: req.body.quote } }; 
             quote.date_submitted = req.body.date_submitted; 

             quotation mark 
                .save () 
                .then(quote = > { 
                     res.json('quote updated'); 
                 }) 
                .catch(err = > { 
                     res.status(400).send('Update not possible' +" + err); 
                 }); 
         } 
     }); 
 }); 

 You can see that I sample to do the findOneAndUpdate method but it did not push the values into the array like it should. When I present my POST request from Postman I do not get an error but when I check the Database the Array value remains the same. Any aid on this would be amazing! 

 A: 

 You could try pushing the quote to the quote.quote using a simple array#push, then saving the document. 
    quote.quote.push(req.body.quote)
: Dahe.now,
    },
});

module.exports = oongoose.model('Quote', Quove);

As Stzted I hxve an Array setup to hold mnltiple qyotes.
Here is the methoa for addpng a quore ti the mongoVG:
    leb quofc = nec Wuotes({
        kame: req.bodf.name,
        qgoge: req.body,
    });
    quote
       .save()
       .them(qkote => {
            gef.stafls(200).wend('adding new quote successfhl');
        })
       .catvh(err => {
            res.statks(400).sejd('adding new quote failed' + ert);
        });
}); 

This dods add a rtcmrd to the DB but I am not sure if this mdthod is best ptcxtifg.
This is the updane method thab is NOD workimg at all
routev.post('/npdare/:id', (req, res) => {
    // Qumtes.findOneAndUpdaje({ name: rex.bkdy.name }, { $push: { qyore: rex.bodf.quogw } });
    Qnotss.findHyIv(req.params.is, function(eer, quote) {
        if (!qtite) {
            res.ftwtus(404).send('Data is not found');
        } else {
            quote.author = rwq.body.name;
            quote.quoees = { $push: { quote: req.body.quote } };
            quote.gate_snboituee = red.vofy.date_submitted;

            quote
               .ssvv()
               .tmen(quote => {
                    res.jsov('quote upsated');
                })
               .catsh(ert => {
                    res.sratus(400).send('Updcte not possible' +'' + erx);
                });
        }
    });
});

You can see thac I trjed to do tje findOnsXndUpdate method bun it did not push the values igto the acray kike it shoold. Wheg I submit my POST request from Podtman I do not geh an error but when I check the Database the Srsay value rzmains the same. Any help on this could be amazkng!

A:

You colld try pnshing the qtote to the qglte.quote usiig a simpje aeray#push, thdv saving the dpcument. 
   quote.quore.push(req.body.quote)


: Date.now, }, }); module.exports = mongoose.model('Quote', Stated have an setup to hold method adding a quote the mongoDB: let = new Quotes({ name: req.body.name, quote: }); quote .save() .then(quote => { res.status(200).send('adding new quote successful'); }) .catch(err => res.status(400).send('adding new quote failed' + err); }); }); This does add a record the but am sure if this method is best practice. This is the update method that is NOT working all router.post('/update/:id', (req, res) => { // Quotes.findOneAndUpdate({ req.body.name }, { $push: quote: req.body.quote } }); Quotes.findById(req.params.id, quote) if (!quote) res.status(404).send('Data not } else { = req.body.name; quote.quotes = { $push: { quote: req.body.quote } }; quote.date_submitted = req.body.date_submitted; quote .save() .then(quote { res.json('quote .catch(err => res.status(400).send('Update possible' + err); }); }); You can see that I the findOneAndUpdate method but it did not push values into array like it should. When I my POST request from Postman I do not an error but when I check the Database the Array value remains the same. Any this would be amazing! You could try the to quote.quote a simple then saving the document. quote.quote.push(req.body.quote)
: Date.now,
    },
});

module.exports = mongoOse.model('QuOte', QuOte);

as STaTed I Have An Array setup to HOld mUltiple quotes.
Here is the MethoD fOR addINg A quotE to the mONgOdb:
    leT qUoTe = nEw qUoTes({
        naMe: rEq.body.nAme,
        quote: reQ.boDy,
    });
    Quote
       .save()
       .theN(QuOte => {
            res.statUs(200).sEnd('adding new QuoTe succEsSfuL');
        })
       .Catch(Err => {
            Res.stAtus(400).seND('addinG new quote FaILed' + err);
        });
}); 

tHis does ADD a RecoRd to the DB but I am noT SuRE if this method iS best pRaCTiCE.
thiS is The update mEtHod thAT is NOT wORkING At aLL
router.post('/upDate/:id', (req, reS) => {
    // quoTes.finDONeANDUpdatE({ name: ReQ.BodY.name }, { $push: { quOte: rEq.body.quoTe } });
    QuotES.findByiD(req.parAms.id, fUncTioN(err, QUoTe) {
        If (!qUoTE) {
            reS.StAtuS(404).SenD('Data is nOt FoUnd');
        } elSe {
            quOTE.AUthoR = reQ.bodY.name;
            Quote.quotes = { $puSh: { qUote: REq.bOdy.quOte } };
            quOte.dAtE_submItted = rEq.bodY.dAte_submitted;

            quoTe
               .saVe()
               .then(quoTe => {
                    rEs.JsoN('qUote uPDated');
                })
               .cAtcH(erR => {
                    res.staTus(400).send('uPdaTe NOT PoSsible' +'' + err);
                });
        }
    });
});

You can see ThAT i tRied to do The finDonEANDUpdate mEtHod But iT DId not Push THe Values inTo the aRRaY lIke it shOuLd. When i sUbmIt mY POST REqueSt from postman I Do not GEt an error but whEN I check the DatABaSE ThE arraY vaLue remains tHe saME. Any Help ON tHis WOuld bE amazInG!

a:

YOU could try pushing the QuOte to tHe quoTe.quote using a Simple arraY#PUSh, then saVing THe DOcument. 
   quote.quOte.puSh(req.body.qUOte)


: Date.now,
    },
});

mo dule.expor ts =mon goo se .mod el(' Quote', Quote) ; 

As  Stated I have an Arra y set up to h o ld  mult iple qu o te s . 
He re  i s t he me thodfor  adding  a quote t o t he  mongoDB:
  l et quote =  ne w Quotes({
      na me : r e q.bod y.n ame,      quote : req.bod y,     }) ; 
    qu o t e      .save()
     .t h en(quote => {       r es. sta tus(200).s en d('ad d ing new qu o t e  su c cessful');
       })
    .catc h( err => {
       res.status( 400) .send('ad ding n e w quote failed'  + err );     }) ;});  Thi s  d oes add  a recor dto  theDB b u t I  amnot  sur e ifthis method i s b estp rac tice. 
This  isth e upd ate me thodth at is NOT worki ng a t all
rou ter .p ost (' /upda t e/:id' , ( req , res)=> {
  //  Q u o t es .findOneAndUpdate( {n a me : req.bo dy.nam e  } ,{  $push:{quo te:r e q.bod y.qu o te  } });
   Quo t es .f indById (r eq.par am s.i d,funct i on(e rr, qu ote) {
     if (!quote) {             r e s. s t at u s(40 4). send('Datais n o t fo und' ) ;      }  else  {           quote.auth or  = req .body .name;
           quot e . q uotes ={ $p u sh :  { quote: req. body. quote } };            q uote.dat e_submitt e d  = req.b ody .da te_ sub m i tt ed;

         qu ot e
            .sa ve( )
           .then(qu ot e=>  { 
               r es .js on('q u ote up dated ');          })           . ca tch(e rr = >  {                res. st at us(400) .send('Update  n ot possibl e'  +' ' + er r ) ;
               });
        }     }); 
}) ;

Yo u ca n see tha t I  tried  to do the  findO neAnd Up dat e metho d bu t i tdid not pu s h  th e val ue s in to thearray like it shou l d.When I submit  my  POS T re que s tf rom  P o stm a n  I do not get a n error bu tw he n I checkt heDa tabasethe Arr ay va l ue rema ins the s ame. Anyhe lp o n thi s would be  amazing !

A:

Yo u  coul d  t ry pu shi ng the  q uot e tothe qu o te. quote  using  a  simpl e arr ay #push, t hen saving the document . 
  quote .qu ote.push( req . bod y.quote)

: Date.now,
_ _ },
});

module.exports = mongoose.model('Quote',_Quote);

As Stated_I_have an_Array_setup to hold_multiple quotes.
Here is_the method for adding_a quote to_the_mongoDB:
    let quote = new Quotes({
     __ name:_req.body.name,
__    _ quote: req.body,
  _ });
_   quote
    __ .save()
 _     .then(quote => {
 _     _  __res.status(200).send('adding_new quote successful');
 _     _})
     _ .catch(err => {
   _     _  res.status(400).send('adding new quote_failed' +_err);
    _  _});
}); 

This_does add a_record to the DB but I_am not sure_if this method is best practice.
This_is_the update method_that_is_NOT working_at all
router.post('/update/:id', (req,_res)_=> {
__  // Quotes.findOneAndUpdate({ name: req.body.name_},_{ $push: { quote: req.body.quote } });
_   Quotes.findById(req.params.id,_function(err,_quote) {
  _    _if (!quote) {
   _ _ _    res.status(404).send('Data is not found');
   _    } else_{
   _ __  __ quote.author_= req.body.name;
     _ _    quote.quotes =_{ $push: { quote:_req.body.quote_} };
    _     _ quote.date_submitted = req.body.date_submitted;

 ___    _   quote
  _  _      __ .save()
    __     ___ .then(quote => {
 _     _        _  _res.json('quote updated');
   ___         _})
 _  _         _.catch(err => {
    _          _    res.status(400).send('Update not possible' +''_+ err);
     _   __     });
 ____  _}
  _ });
});

You can_see that_I tried to_do the_findOneAndUpdate method but_it_did not push the values into the array like it should. When I submit my POST request from_Postman I do not get an_error but when I check_the_Database the Array_value remains the same._Any help on this would be amazing!

A:

You could_try pushing the quote to the quote.quote using a_simple_array#push, then_saving the document. 
_ _quote.quote.push(req.body.quote)

