Hello i'm trying to fetch some partner names from my mongodb database and put them into a list of variables. But it for some reason loses it's definition when I try to export it. What's going on?
This is the first file.
///// mongodb.js /////
const MongoClient = require('mongodb').MongoClient;
const assert = require('assert');
const findDocuments = function(db, callback) {
  // Get the documents collection
  const collection = db.collection('partners');
  // Find some documents
  collection.find({}).toArray(function(err, docs) {
    assert.equal(err, null);
    callback(docs);
  });
};
// Connection URL
const url = 'mongodb://localhost:27017';
// Database Name
const dbName = 'yarle';
// Use connect method to connect to the server
MongoClient.connect(url, function(err, client) {
  assert.equal(null, err);
  console.log("Connected succesfully to Database");
  const db = client.db(dbName);
  findDocuments(db, function(docs) {
    module.exports = {
      partner1: console.log(docs[0]['partner_name']),
      partner2: console.log(docs[1]['partner_name']),
      partner3: console.log(docs[2]['partner_name']),
    };
    client.close();
  });
});
//console.log(Object.keys(partners[0][0]));
And this is the end file.
///// Endfile.ts /////
import { Request, Response } from 'express';
import { PartnersList } from './data.d';
var partners = require( './mongodb.js');
console.log(partners.partner1);
const titles = [
  partners.partner1,
  partners.partner2,
  partners.partner3,
];
 
    