Answer the question
In order to leave comments, you need to log in
How to work with this mongo db?
RESOLVED! I'M A FOOL! IT IS NECESSARY ON THE SITE TO ALLOW ALL IP TO CONNECT!
I really ask for your help, all day of flour I
started mastering Mongo, found Mongoose, it seems clear, I created a console application that accesses my cluster on the mongo website, so I decided to transfer it to a Linux server, flew
[Mongo Driver Error]:Timed out after 10000 ms while waiting to connect.
npm i mongodb
const MongoClient = require('mongodb').MongoClient;
const url = 'mongodb+srv://meow:ПАРОЛЬ@meow-ix3up.mongodb.net/test?retryWrites=true&w=majority';
const dbName = 'test';
const client = new MongoClient(url, { useNewUrlParser: true,useUnifiedTopology: true });
const db = client.db(dbName);
const collection = db.collection('uzvers');
db.uzvers.insertOne({1:'meow'})
Answer the question
In order to leave comments, you need to log in
Use mongoose
Connection
const mongoose = require('mongoose');
const url = 'mongodb+srv://meow:ПАРОЛЬ@meow-ix3up.mongodb.net/test?retryWrites=true&w=majority';
mongoose.connect(url, { useNewUrlParser: true, useUnifiedTopology: true });
const mongoose = require('mongoose');
const { Schema } = require('mongoose');
const Uzver = new Schema(
{
sho: String
}
)
const Uzvers = mongoose.model('Uzvers', Uzver);
module.exports = {
Uzvers
};
const { Uzvers } = require('./uzvers');
const uzver = new Uzvers({
sho: 'Meow'
});
uzver.save().then(() => 'Сохранено');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question