Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

check if the collection exists in mongodb database mongoose

const mongoose = require('mongoose');
const mongoURI = 'mongodb://localhost:27017/mydb'
// notice the mongoose.createConnection instead of mongoose.connect
const conn = mongoose.createConnection(mongoURI);
conn.on('open', function () {
    conn.db.listCollections().toArray(function (err, collectionNames) {
      if (err) {
        console.log(err);
        return;
      }
        console.log(collectionNames);
        conn.close();
    });
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: find the sum of an attribute in sequelize 
Javascript :: unexpected token react 
Javascript :: javascript recursion 
Javascript :: create javascript map 
Javascript :: how to create new route in express 
Javascript :: what is axios used for 
Javascript :: react native bottom sheet above the bottom menu 
Javascript :: useselector in redux 
Javascript :: javascript bind multiple arguments 
Javascript :: .has javascript 
Javascript :: what are escape characters in javascript 
Javascript :: discord js check every x minutes 
Javascript :: dot notation vs bracket notation 
Javascript :: JavaScript substring Syntax 
Javascript :: create javascript set 
Javascript :: how to access ::after Pseudo-Elements from javascript 
Javascript :: npm i images=pdf 
Javascript :: sequelize migration enum 
Javascript :: react datepicker documentation 
Javascript :: javascript infinite while loop 
Javascript :: react responsive nav bar 
Javascript :: react tweet embed 
Javascript :: js update query string without refresh 
Javascript :: run javascript in atom 
Javascript :: bind() method 
Javascript :: javascript string methods cheat sheet 
Javascript :: not .js 
Javascript :: binance js 
Javascript :: create and save xml file in javascript 
Javascript :: react functional component 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =