Skip to content

Instantly share code, notes, and snippets.

View codedeep79's full-sized avatar

Nguyễn Trung Hậu codedeep79

View GitHub Profile
@codedeep79
codedeep79 / Cài đặt GCC trên Ubuntu.md
Last active August 5, 2022 09:58
Cài đặt GCC trên Ubuntu

The default Ubuntu repositories contain a meta-package named “build-essential” that includes the GNU compiler collection, GNU debugger, and other development libraries and tools required for compiling software.

To install the Development Tools packages, run the following command as root or user with sudo privileges :

sudo apt update
sudo apt install build-essential

The command installs a lot of packages, including gcc, g++ and make.

Verify that the GCC compiler is successfully installed by running the following command that prints the GCC version: gcc --version

@codedeep79
codedeep79 / Cài đặt OpenCart trên Ubuntu với LAMP Stack.md
Created August 5, 2022 09:11
Cài đặt OpenCart trên Ubuntu với LAMP Stack

Prerequisites

Step 1 — Creating a MySQL Database and User for OpenCart

To get started, log into the MySQL root (administrative) account by issuing the following command: sudo mysql -u root -p To create a database, database user, and grant all privileges to the database user run the following commands:

mysql> CREATE DATABASE opencart DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
mysql> CREATE USER 'opencartuser'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password';
@codedeep79
codedeep79 / Cập nhật dữ liệu trong MongoDB (phần 2).md
Last active August 4, 2022 05:04
Cập nhật dữ liệu trong MongoDB (phần 2)

The updateMany() method allows you to update all documents that satisfy a condition.

The following shows the syntax of the updateMany() method:

db.collection.updateMany(filter, update, options)

In this syntax:

  • The filter is a document that specifies the condition to select the document for update. If you pass an empty document ({}) into the method, it’ll update all the documents the collection.
  • The update is a document that specifies the updates to apply.
@codedeep79
codedeep79 / Cập nhật dữ liệu trong MongoDB (phần 1).md
Created August 4, 2022 03:03
Cập nhật dữ liệu trong MongoDB (phần 1)

The updateOne() method allows you to update a single document that satisfies a condition.

The following shows the syntax of the updateOne() method:

db.collection.updateOne(filter, update, options)

In this syntax:

  • The filter is a document that specifies the criteria for the update. If the filter matches multiple documents, then the updateOne() method updates only the first document. If you pass an empty document {} into the method, it will update the first document returned in the collection.
  • The update is a document that specifies the change to apply.
@codedeep79
codedeep79 / Xóa dữ liệu trong MongoDB (phần 2).md
Created August 4, 2022 02:24
Xóa dữ liệu trong MongoDB (phần 2)

The deleteMany() method allows you to remove all documents that match a condition from a collection.

The deleteMany() has the following syntax:

db.collection.deleteMany(filter, option)

In this syntax:

  • filter is a document that specifies deletion criteria. If the filter is an empty document {}, the deleteMany() method will delete all documents from the collection.
  • option is a document that specifies the deletion option.
@codedeep79
codedeep79 / Xóa dữ liệu trong MongoDB (phần 1).md
Last active August 4, 2022 02:04
Xóa dữ liệu trong MongoDB (phần 1)

The deleteOne() method allows you to delete a single document from a collection.

The deleteOne() method has the following syntax:

db.collection.deleteOne(filter, option)

The deleteOne() method accepts two arguments:

  • filter is an required argument. The filter is a document that specifies the condition for matching the document to remove. If you pass an empty document {} into the method, it’ll delete the first document in the collection.
  • option is an optional argument. The option is a document that specifies the deletion options.
@codedeep79
codedeep79 / Lấy dữ liệu trong MongoDB (phần 3).md
Created August 3, 2022 13:35
Lấy dữ liệu trong MongoDB (phần 3)

In this tutorial, you’ll how to use the MongoDB projection that allows you to select fields to return from a query. In MongoDB, projection simply means selecting fields to return from a query.

To determine if a field is included in the returned documents, you use the following syntax: { <field>: value, ...}

If the value is 1 or true, the is included in the matching documents. In case the value is 0 or false, it is suppressed from the returned documents.

If the projection document is empty {}, all the available fields will be included in the returned documents.

To specify a field in an embedded document, you use the following dot notation:

@codedeep79
codedeep79 / Lấy dữ liệu trong MongoDB (phần 2).md
Created August 3, 2022 13:06
Lấy dữ liệu trong MongoDB (phần 2)

The find() method finds the documents that satisfy a specified condition and returns a cursor to the matching documents.

The following shows the syntax of the find() method:

db.collection.find(query, projection)

query: The query is a document that specifies the criteria for selecting documents from the collection. If you omit the query or pass an empty document({}), the find() returns a cursor that returns all documents in the collection.

projection: The projection is a document that specifies the fields in the matching documents to return. If you omit the projection argument, the find() method returns all fields in the matching documents.

@codedeep79
codedeep79 / Lấy dữ liệu trong MongoDB (phần 1).md
Last active August 3, 2022 12:48
Lấy dữ liệu trong MongoDB (phần 1)

The findOne() returns a single document from a collection that satisfies the specified condition.

The findOne() method has the following syntax:

db.collection.findOne(query, projection)

The findOne() accepts two optional arguments: query and projection.

  • The query is a document that specifies the selection criteria.
  • The projection is a document that specifies the fields in the matching document that you want to return.
@codedeep79
codedeep79 / MongoDB insertMany.md
Last active August 3, 2022 09:22
MongoDB insertMany

The insertMany() allows you to insert multiple documents into a collection. Here is the syntax of the insertMany() method:

 db.collection.insertMany(
   [document1, document2, ...],
   {
      writeConcern: <document>,
      ordered: <boolean>
   }
)