Javatpoint Logo
Javatpoint Logo

Node.js MongoDB Select Record

The findOne() method is used to select a single data from a collection in MongoDB. This method returns the first record of the collection.

Example

(Select Single Record)

Select the first record from the ?employees? collection.

Create a js file named "select.js", having the following code:

Open the command terminal and run the following command:

Node.js Select record 1

Select Multiple Records

The find() method is used to select all the records from collection in MongoDB.

Example

Select all the records from "employees" collection.

Create a js file named "selectall.js", having the following code:

Open the command terminal and run the following command:

Node.js Select record 2

You can see that all records are retrieved.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA