Node.js & Express From Scratch [Part 7] - Update & Delete Articles

preview_player
Показать описание
In this video we will add the functionality to update and delete articles in MongoDB. We will also work with jQuery and Ajax to make a safe delete request

CODE: Full code for this series

COURSE: Full course this project is based on

SUPPORT: We spend massive amounts of time creating these free videos, please donate to show your support:

FOLLOW TRAVERSY MEDIA:
Рекомендации по теме
Комментарии
Автор

you can add "pretty : true" to the JSON object passed into your .pug file and it will add horizontal and inline spacing.
This will save you having to add breaks between elements and clean up the code in your .pug file

wshorrock
Автор

Great series.
Adding some kind of authentication functionality would actually be extremely useful, if not necessary.
Furthermore, you forgot to include a tutorial on how to dynamically change the active class of navbar's item, based on the current page.
Overall, the series was really educational and easy to understand.
Thanks for the amazing course, Brad!

marktwain
Автор

You could also do :

$.ajax({
type : 'DELETE',
url : e.target.pathname,
success : function (res) {
alert('Deleting Article');
window.location.href = '/';
},
error: function (err) {
console.log(err);
}
});

scottyzen
Автор

Completed. Wait for next one ;)
Nice job and thanks.

vixeven
Автор

Nice tuts Brad...I like the ajax delete style but u can still delete through form:

form(method='post' action='/article/'+ article._id)

It works...!

MichaelAbebreseAgyeman
Автор

nice, looking forward to see where it goes from here

fathersondiecast
Автор

Hi there, thank you very much for this series. It helped me a lot with my school assignment.

Tm
Автор

Looking forward for the deployment as well! Thank you

haniyahya
Автор

for anyone coming across this video from the time of this message remove is being deprecated please use deleteOne, deleteMany, or bulkWrite instead. the delete one follows as showing with the parms taken in I recommend checking if this is changed if you are seeing this comment in the future

Unnamed
Автор

Hi. Do you know how I can validate that if a schema has a field as a foreign key it does not allow me to delete the record?

ggforniteclips
Автор

Followed along and got the app like you did.

Would love to see how to deploy it online.

Thanks again.

socialartistTV
Автор

Hey Brad, great tutorial as other ones, couldn't understand why not to use regular form post for delete operation ?

vishals
Автор

HI! Thank you for great tutorial. I am learning with these videos. But in this part i encountered one problem. I followed all your instruction but after pressing Delete button, nothing isn't deleted and couldn't get to the home page. I have checked Chrome Console there is one error like this: $.ajax is not a function. I have installed ajax in node by "npm install ajax". What can I do? Thank in advance for your help!

shahinabdullayev
Автор

What is the difference between PUT and POST method when updating the database?

paolo-
Автор

Hi Brad :)
why are you using POST method instead of PUT to update article?

maciejrusek
Автор

I am at the deleting articles part, however, after following along and then pressing delete in my browser nothing happens except in the url after id the browser adds a #; again nothing happens. Any help would be greatly appreciated. Thank you.

mateva
Автор

Thank you so much Brad! You are the man

zrkmedia
Автор

Kaboom. Da bomb videos. Thanks for posting.

kamaboko
Автор

I was getting the error "$.ajax is not a function", which is because jQuery-slim does not support ajax calls. To resolve, just use jquery-min instead of jquery-slim-min

Loppy
Автор

Thanks Man, Keep up the good work.God Bless

samsonwandah
welcome to shbcf.ru