# Dart and MongoDB Tutorial #1: Using the mongo_dart package

In this video series, we will learn how to talk to a MongoDB database with Dart, using the [**mongo\_dart**](https://pub.dartlang.org/packages/mongo_dart) package. MongoDB is a well-known NoSQL database that stores its items as JSON documents (BSON to be exact). At the end of this video, you will be comfortable setting up a MongoDB database, connecting to your database, creating your own collections and performing CRUD operations.

## **Prerequisites**

[Download and Install MongoDB](https://docs.mongodb.com/manual/administration/install-community/) to use the database. Alternatively use the [official docker image](https://hub.docker.com/_/mongo).

[Checkout the starter branch](https://github.com/graphicbeacon/dart_mongo/tree/starter) to follow along. You will learn much better this way. I know it’s convenient just watching, but doing so will be much more fulfilling.

In the root directory of the project update your dependencies:

```bash
$ pub get
```

%[https://youtu.be/Y5X5rdzFScs] 

## **Setup your database**

Run Mongo server running using the startup commands on the documentation page for your Operating System.

Log in to MongoDB by entering `mongo` in the terminal. Create a database and collection:

```bash
> use test;
switched to db test
> db.createCollection('people');
{ "ok" : 1 }
> exit
bye
```

Upload the `people.json` file into the `people` collection we just created. This file is in the root project.

```bash
$ mongoimport --jsonArray -d test -c people --file people.json
... connected to: localhost
... imported 100 documents
```

To confirm all is good, log in to Mongo and check the collection:

```bash
$ mongo
...
> use test
switched to db test
> show collections
people
> db.people.find();
[{ "id": 1, "first_name": "Nolly", "last_name": "Montfort", "email": "nmontfort0@archive.org", "gender": "Male", "ip_address": "6.125.126.90" },
...
...
]
```

Good job! Let’s continue with the video.

[Watch on YouTube](https://youtu.be/Y5X5rdzFScs)
