MongoDB
 sql >> Teknologi Basis Data >  >> NoSQL >> MongoDB

Terhubung ke MongoDB Atlas Cluster db dengan aplikasi asli-reaksi

Saya pikir Anda harus menulis ulang kode mengikuti format yang disarankan oleh mongodb di sini:

https://mongodb.github.io/node-mongodb -native/api-articles/nodekoarticle1.html

Jadi intinya:

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

    //make sure to check connection string is correct here, since this depends on the whether you are running standalone, replica, sharded cluster 

    const uri = "mongodb+srv://<userName>:<password>@testcluster1-dbdq3.mongodb.net/test?retryWrites=true&w=majority";


    MongoClient.connect(uri, { useNewUrlParser: true }, function(err, client) {

       if (err) {

             //error

       } else {

             var collection = client.db('test').collection('devices');

             //client.close() should be called after you are done performing actions such as collection.update, etc.

       }
    });


  1. Redis
  2.   
  3. MongoDB
  4.   
  5. Memcached
  6.   
  7. HBase
  8.   
  9. CouchDB
  1. Apa yang setara dengan perintah shell collection.getIndexes() di pymongo?

  2. Bagaimana cara mengakses koleksi yang sudah ada sebelumnya dengan Mongoose?

  3. MongoDB $substrBytes

  4. Bagaimana cara mengambil aturan validator koleksi MongoDb?

  5. Bagaimana cara mengekspor data mongoDB ke dalam format CSV?