In this video we build all the necessary functions to properly insert the new player into our MongoDB database. You also learn about how to get to a new page after you've successfully completed a function with the browserHistory method from React router.
- [Emmanuel] In the last video,…we added a few fields to our form,…now we need to add the proper functions,…in order to add a new player to our database,…so let's get to it.…So the first thing I want you to do…is get into the New.jsx file…and then we'll add a few imports,…so the first one, we need to do is withRouter…from react-router-dom…and then import the Players schema,…so basically we'll import the Players file…from our api/players,…perfect, so the next thing we need to do…is basically create the functions,…so whenever we actually use the form,…we'll submit it to the database…and we need to insert a new player,…so we'll call this function submitPlayer,…like so, which takes an event…and then we'll make sure we preventDefault event,…so we control the expanse of that between submission…and then we'll use the Players,…that we've imported from our api…and insert in our database a new player,…so what I'm going to do to make this faster,…I'm going to go in the apis here, so open players…and copy and paste this entire section here like so…
- Setting up your editor
- Understanding the file structure and player components
- Setting up static data
- Routing with React
- Creating a schema and player form
- Building functions to add a player
- Adding a user login
- Assigning players to the user
- Securing database transactions
- Editing and deleting players
- Using Chart.js to display team stats
Skill Level Intermediate
Q: This course was updated on 05/01/2018. What changed?
A: We updated 13 videos to reflect the changes in the latest versions of Meteor (v1.6) and Node.js (v8).
1. Setting Up
2. React Refresher: Basic Player View
3. Reduce Player Stats
4. Players CRUD and Team View
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.