Loading lesson path
Node.js
Database Integration focused on Node.js MySQL and related concepts.
Node.js can be used in database applications.
To create a database in MySQL, use the "CREATE DATABASE" statement:
To create a table in MySQL, use the "CREATE TABLE" statement.
To fill a table in MySQL, use the "INSERT INTO" statement.
To select data from a table in MySQL, use the "SELECT" statement.
When selecting records from a table, you can filter the selection by using the "WHERE" statement:
Use the ORDER BY statement to sort the result in ascending or descending order.
You can delete records from an existing table by using the "DELETE FROM" statement:
You can delete an existing table by using the "DROP TABLE" statement:
You can update existing records in a table by using the "UPDATE" statement:
You can limit the number of records returned from the query, by using the "LIMIT" statement:
You can combine rows from two or more tables, based on a related column between them, by using a JOIN statement.
Node.js can be used in database applications.
To create a database in MongoDB, start by creating a MongoClient object, then specify a connection URL with the correct ip address and the name of the database you want to create.
A collection in MongoDB is the same as a table in MySQL
To insert a record, or document as it is called in MongoDB, into a collection, we use the insertOne() method.
In MongoDB we use the find and findOne methods to find data in a collection.
When finding documents in a collection, you can filter the result by using a query object.
Use the sort() method to sort the result in ascending or descending order.
To delete a record, or document as it is called in MongoDB, we use the deleteOne() method.
You can delete a table, or collection as it is called in MongoDB, by using the drop() method.
You can update a record, or document as it is called in MongoDB, by using the updateOne() method.
To limit the result in MongoDB, we use the limit() method.
MongoDB is not a relational database, but you can perform a left outer join by using the $lookup stage.