Why can't I set up a database with Mongoose?

98
January 10, 2020, at 11:20 PM

I am attempting to use Mongoose for the first time and setting up an example database. However, after I run this code nothing happens.

It's processing something but no output or anything new in the database.

Here is my code:

const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost:27017/fruitsDB", {
  useUnifiedTopology: true,
  useNewUrlParser: true
});
const fruitSchema = new mongoose.Schema({
  name: String,
  rating: Number,
  review: String
});
const Fruit = mongoose.model("Fruit", fruitSchema);
const fruit = new Fruit({
  name: "Apple",
  rating: 7,
  review: "Great Fruit ! 10/10"
});
fruit.save();

Here are all my dependencies:

{
    "mongodb": "^3.4.1",
    "mongoose": "^5.8.6"
}
READ ALSO
Node.js gRPC Connection with tool proto file

Node.js gRPC Connection with tool proto file

I am trying to create a Nodejs gRPC connection with a tool I am running on my machine called Pachyderm

105
Where do NodeJs files go in a Linux container?

Where do NodeJs files go in a Linux container?

I am trying to setup a container for my nodejs applicationI am doing a multistage dockerfile and have the builder part done

84
Preventing SQL injection in Node.js

Preventing SQL injection in Node.js

Is it possible to prevent SQL injections in Nodejs (preferably with a module) in the same way that PHP had Prepared Statements that protected against them

111
Define a string variable in a NodeJS file by fetching the Nth line from a local text file?

Define a string variable in a NodeJS file by fetching the Nth line from a local text file?

I have the following script (shown below shortened and excerpted with only the relevant segments) using Nodemailer for NodeJS to e-mail the results of a daily AV scan with a variety of system information embedded

78