$ brew install mongodb-community- Installs mongodb server on your machine.1$ brew services start mongodb-community- Starts mongodb server locally.2$ npm install mongodb- Installs mongodb node package.
db/mongo-config.js:
import { MongoClient } from "mongodb";
const URI = "mongodb://localhost:27017/";
const insertStuff = async () => {
const client = await new MongoClient(URI).connect();
const db = client.db("fec");
const collection = db.collection("items");
await collection.insertOne({ name: "stuff" });
await client.close();
};
await insertStuff();- Bulk writes: https://docs.mongodb.com/manual/core/bulk-write-operations/
- API Docs: https://mongodb.github.io/node-mongodb-native/4.0/
- Shell Docs: https://docs.mongodb.com/mongodb-shell/connect/#std-label-mdb-shell-connect
2By default, this will run on localhost:27017. ↩
