JAVASCRIPT 23
Web Technologies - Lecture 3 Guest on 7th March 2022 09:26:21 AM
  1. promises
  2. are required to execute the tasks synchronicly
  3.  
  4. "live server", an extension is installed.
  5.  
  6. callback requires the function to be called within the function all the time
  7. callback hell - is a problem as it can cause the code to be stuck if there is issue in any function, can be hard to troubleshoot.
  8.  
  9. To resolve this issue, an alternative way is used which is known as promises.
  10. Promise consists of resolve and reject.
  11.  
  12. Another way to resolve this issue is async-await which is the most simple method.
  13. Uses the keyword async before the function
  14. For example, a function that needs to wait as fetching data can take sometime so await is used.
  15.  
  16. so there are now three ways to execute the code synchronicly.
  17. Callback (The oldest method which has issues like callback hell)
  18. Promise (This method solves the callback hell)
  19. Async Wait (This one is more easier to implement and is latest)
  20.  
  21. NoSQL (The famous one is MongoDB)
  22. NoSQL is used as it is faster, it is called document oriented.
  23. All Data can be called through a key
  24.  
  25. The different keywords for MongoDB are mapped.
  26. RDBMS      MongoDB
  27. Database > Database
  28. Table,View > Collection
  29. Row > Document
  30. Column > Field
  31. Join > Embedded Document
  32. Foreign Key > Reference
  33. Partition > Shard
  34.  
  35. By default, MongoDB uses home directory.
  36. in CMD of MongoDB
  37. mongoimport -d academic -c courses --file courses.json --jsonArray
  38.  
  39. to connect to MongoDB - install extension in VS Code
  40.  
  41. show dbs
  42. to show all database
  43.  
  44. use academic
  45. - to switch to the database
  46.  
  47. show collections
  48. it will show all the collections
  49.  
  50.  
  51. db.courses.find({courseid: 1)}
  52. - to retreive the row with courseID 1
  53.  
  54. we can also write JS functions in MongoDB
  55.  
  56. for(let col in db.courses.findOne()) {print(col)}
  57.  
  58. driver is required to connect to nodejs
  59. moongoose will be used as a driver

Coding Base is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.