bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/Node.js

Node.js

Database Integration

Database Integration focused on Node.js MySQL and related concepts.

Lesson 1

Node.js MySQL

Node.js MySQL

2 min
Read lesson →
Lesson 2

Node.js MySQL Create Database

Creating a Database To create a database in MySQL, use the "CREATE DATABASE" statement: Example Create a database named "mydb": let mysql = require('mysql'); let con = mysql.createConnection({ host:…

2 min
Read lesson →
Lesson 3visual

Node.js MySQL Create Table

Creating a Table To create a table in MySQL, use the "CREATE TABLE" statement. Make sure you define the name of the database when you create the connection: Example Create a table named "customers":…

2 min
Read lesson →
Lesson 4visual

Node.js MySQL Insert Into

Insert Into Table To fill a table in MySQL, use the "INSERT INTO" statement. Example Insert a record in the "customers" table: let mysql = require('mysql'); let con = mysql.createConnection({ host: "…

3 min
Read lesson →
Lesson 5visual

Node.js MySQL Select From

Selecting From a Table To select data from a table in MySQL, use the "SELECT" statement. Example Select all records from the "customers" table, and display the result object: let mysql = require('mys…

4 min
Read lesson →
Lesson 6visual

Node.js MySQL Where

Select With a Filter When selecting records from a table, you can filter the selection by using the "WHERE" statement: Example Select record(s) with the address "Park Lane 38": let mysql = require('m…

2 min
Read lesson →
Lesson 7visual

Node.js MySQL Order By

Sort the Result Use the ORDER BY statement to sort the result in ascending or descending order. The ORDER BY keyword sorts the result ascending by default. To sort the result in descending order, use…

3 min
Read lesson →
Lesson 8visual

Node.js MySQL Delete

Delete Record You can delete records from an existing table by using the "DELETE FROM" statement: Example Delete any record with the address "Mountain 21": let mysql = require('mysql'); let con = mys…

2 min
Read lesson →
Lesson 9

Node.js MySQL Drop Table

Delete a Table You can delete an existing table by using the "DROP TABLE" statement: Example Delete the table "customers": let mysql = require('mysql'); let con = mysql.createConnection({ host: "loca…

2 min
Read lesson →
Lesson 10visual

Node.js MySQL Update

Update Table You can update existing records in a table by using the "UPDATE" statement: Example Overwrite the address column from "Valley 345" to "Canyon 123": let mysql = require('mysql'); let con…

2 min
Read lesson →
Lesson 11visual

Node.js MySQL Limit

Limit the Result You can limit the number of records returned from the query, by using the "LIMIT" statement: Example Select the 5 first records in the "customers" table: let mysql = require('mysql')…

2 min
Read lesson →
Lesson 12

Node.js MySQL Join

Join Two or More Tables You can combine rows from two or more tables, based on a related column between them, by using a JOIN statement. Consider you have a "users" table and a "products" table: user…

3 min
Read lesson →
Lesson 13

Node.js MongoDB

Node.js can be used in database applications. One of the most popular NoSQL database is MongoDB. MongoDB To be able to experiment with the code examples, you will need access to a MongoDB database. Y…

2 min
Read lesson →
Lesson 14visual

Node.js MongoDB Create Database

Creating a Database 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.…

2 min
Read lesson →
Lesson 15

Node.js MongoDB Create Collection

A collection in MongoDB is the same as a table in MySQL Creating a Collection To create a collection in MongoDB, use the createCollection() method: Example Create a collection called "customers": let…

2 min
Read lesson →
Lesson 16visual

Node.js MongoDB Insert

Insert Into Collection To insert a record, or document as it is called in MongoDB, into a collection, we use the insertOne() method. A document in MongoDB is the same as a record in MySQL The first p…

5 min
Read lesson →
Lesson 17visual

Node.js MongoDB Find

In MongoDB we use the find and findOne methods to find data in a collection. Just like the SELECT statement is used to find data in a table in a MySQL database. Find One To select data from a collect…

6 min
Read lesson →
Lesson 18visual

Node.js MongoDB Query

Filter the Result When finding documents in a collection, you can filter the result by using a query object. The first argument of the find() method is a query object, and is used to limit the search…

2 min
Read lesson →
Lesson 19visual

Node.js MongoDB Sort

Sort the Result Use the sort() method to sort the result in ascending or descending order. The sort() method takes one parameter, an object defining the sorting order. Example Sort the result alphabe…

2 min
Read lesson →
Lesson 20visual

Node.js MongoDB Delete

Delete Document To delete a record, or document as it is called in MongoDB, we use the deleteOne() method. The first parameter of the deleteOne() method is a query object defining which document to d…

2 min
Read lesson →
Lesson 21

Node.js MongoDB Drop

Drop Collection You can delete a table, or collection as it is called in MongoDB, by using the drop() method. The drop() method takes a callback function containing the error object and the result pa…

2 min
Read lesson →
Lesson 22visual

Node.js MongoDB Update

Update Document You can update a record, or document as it is called in MongoDB, by using the updateOne() method. The first parameter of the updateOne() method is a query object defining which docume…

2 min
Read lesson →
Lesson 23visual

Node.js MongoDB Limit

Limit the Result To limit the result in MongoDB, we use the limit() method. The limit() method takes one parameter, a number defining how many documents to return. Consider you have a "customers" col…

2 min
Read lesson →
Lesson 24

Node.js MongoDB Join

Join Collections MongoDB is not a relational database, but you can perform a left outer join by using the $lookup stage. The $lookup stage lets you specify which collection you want to join with the…

2 min
Read lesson →