- promises
- are required to execute the tasks synchronicly
- "live server", an extension is installed.
- callback requires the function to be called within the function all the time
- 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.
- To resolve this issue, an alternative way is used which is known as promises.
- Promise consists of resolve and reject.
- Another way to resolve this issue is async-await which is the most simple method.
- Uses the keyword async before the function
- For example, a function that needs to wait as fetching data can take sometime so await is used.
- so there are now three ways to execute the code synchronicly.
- Callback (The oldest method which has issues like callback hell)
- Promise (This method solves the callback hell)
- Async Wait (This one is more easier to implement and is latest)
- NoSQL (The famous one is MongoDB)
- NoSQL is used as it is faster, it is called document oriented.
- All Data can be called through a key
- The different keywords for MongoDB are mapped.
- RDBMS MongoDB
- Database > Database
- Table,View > Collection
- Row > Document
- Column > Field
- Join > Embedded Document
- Foreign Key > Reference
- Partition > Shard
- By default, MongoDB uses home directory.
- in CMD of MongoDB
- mongoimport -d academic -c courses --file courses.json --jsonArray
- to connect to MongoDB - install extension in VS Code
- show dbs
- to show all database
- use academic
- - to switch to the database
- show collections
- it will show all the collections
- db.courses.find({courseid: 1)}
- - to retreive the row with courseID 1
- we can also write JS functions in MongoDB
- for(let col in db.courses.findOne()) {print(col)}
- driver is required to connect to nodejs
- moongoose will be used as a driver
Recent Pastes