skip to Main Content

Mongodb – finOne() in mongoose fails with MongoServerError: Expected field collationto be of type object

I am trying to implement a simple registration validation using express and MongoDb but the below line of code always fails with the below error const emailExist = await User.findOne({email: req.body.email}); The Error _node_modulesmongodblibcmapconnection.js:203 callback(new error_1.MongoServerError(document)) ^ MongoServerError: Expected field…

VIEW QUESTION

Connecting to MongoDB database

I am trying to connect to a MongoDB database.I have followed all the steps here https://youtu.be/EcJERV3IiLM but am getting an error. The index.js file looks like this, const dotenv = require('dotenv') dotenv.config() const mongodb = require('mongodb') mongodb.connect(process.env.CONNECTIONSTRING, async function(err,client){ const…

VIEW QUESTION

How to connect to mongodb running inside one container from golang app container – Docker

func GetDatabase() (database *mongo.Database, ctx context.Context, err error) { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() client, err := mongo.NewClient(options.Client().ApplyURI("mongodb://mongodb:27017")) if err != nil { log.Println("database connection error", err) return nil, nil, err } err = client.Ping(context.TODO(), readpref.Primary()) if err…

VIEW QUESTION
Back To Top
Search