Can you please provide the Node.JS script you’re using?
Are you using the MongoDB Node.JS Driver? I see you’re using Mongoose via the directory.
What type of app is this? What is this running on?
const mongoose = require('Mongoose');
mongoose.connect("MongoDB://localhost:<PortNumberHereDoubleCheckPort>/<DatabaseName>", {useNewUrlParser: true});
const <nameOfDbschemahere> = new mongoose.schema({
name: String,
rating: String,
quantity: Number,
someothervalue: String,
somevalue2: String,
});
const Fruit<Assuming as you call it FruitsDB> = mongoose.model("nameOfCollection" , <nameOfSchemeHere>);
const fruit = new Fruit<Because FruitsDB calling documents Fruit for this>({
name: "Watermelon",
rating: 10,
quantity: 50,
someothervalue: "Pirates love them",
somevalue2: "They are big",
});
fruit.save();
In MongoDB when logged in via terminal:
show dbs
Select the DB in this case whatever you named the database by typing: use databasename
show collections
You should then see the fruits collection.
db.fruits.find will then pull up all documents in fruit.
@Brock Just 2 line script requiring mongoose and connecting it.
I just started learning MongoDb and it’s my first MongoDb project trying to connect with Node.js
Is your code complete?
After useNewUrlParser: true there is a comma
Do you have any other parameter before closing the brackets?
May be waiting for more inputs?
That’s bizarre, it’s working fine on my local environment, there shouldn’t be other parameters needed. The comma is because it’s continuing with the parser.
That said, there’s nothing returning because nothing is there @Rahul_pal. You need to build the schema, the DB, etc.
@Rahul_pal if it’s been done correctly, you can do the following to check the work:
In MongoDB when logged in via terminal: show dbs
Select the DB in this case whatever you named the database by typing: use databasename show collections
You should then see the fruits collection. db.fruits.find will then pull up all documents in fruit.
What the freeze is indicating is there is nothing to CD into, you need to not just “connect” it, but you need to “build” it.
hi Rahul ,
i too facing the issue that , i can’t get the data from the local dataBase to the hyper shell when im console logging. Can u help me with this error , And Did your problem solved ?