SQL >> Database teknologi >  >> NoSQL >> MongoDB

connect is not a function når du forbinder til mongodb

Årsagen er, at du skal importere MongoClient-klassen:

const MongoClient = require("mongodb").MongoClient; 

I stedet for følgende linje i din kode: const MongoClient = require("mongodb");

  1. MongoDB: kunne ikke forbinde til serveren

  2. Løs "mongodb/mongoose insert is not a function"

  3. Forbind til MongoDB fra en Azure Function

  4. Tilslut applikationen til en MongoDB Atlas-cluster