@maxim22351

При получения данных через NodeJS в mongoDB получаю в ответ обект?

Если использувать tv.findOne() получаю одну запись.

const {MongoClient} =  require('mongodb')

const client = new MongoClient('mongodb+srv://admin:25Kfu3VbD4nnOut4@cluster0.oogmr.mongodb.net/iptv?retryWrites=true&w=majority')

async function connectMongoDB() {
    try {
        await  client.connect()
        const tv = await client.db().collection('tv');
        console.log( await tv.find())
    } catch (e){
        console.log(e)
    }
}

connectMongoDB()

{
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  [Symbol(kCapture)]: false,
  [Symbol(topology)]: Topology {
    _events: [Object: null prototype] {
      topologyDescriptionChanged: [Array],
      connectionPoolCreated: [Function (anonymous)],
      connectionPoolClosed: [Function (anonymous)],
      connectionCreated: [Function (anonymous)],
      connectionReady: [Function (anonymous)],
      connectionClosed: [Function (anonymous)],
      connectionCheckOutStarted: [Function (anonymous)],
      connectionCheckOutFailed: [Function (anonymous)],
      connectionCheckedOut: [Function (anonymous)],
      connectionCheckedIn: [Function (anonymous)],
      connectionPoolCleared: [Function (anonymous)],
      commandStarted: [Function (anonymous)],
      commandSucceeded: [Function (anonymous)],
      commandFailed: [Function (anonymous)],
      serverOpening: [Function (anonymous)],
      serverClosed: [Function (anonymous)],
      serverDescriptionChanged: [Function (anonymous)],
      topologyOpening: [Function (anonymous)],
      topologyClosed: [Function (anonymous)],
      error: [Function (anonymous)],
      timeout: [Function (anonymous)],
      close: [Function (anonymous)],
      serverHeartbeatStarted: [Function (anonymous)],
      serverHeartbeatSucceeded: [Function (anonymous)],
      serverHeartbeatFailed: [Function (anonymous)]
    },
    _eventsCount: 25,
    _maxListeners: undefined,
    bson: [Object: null prototype] {
      serialize: [Function: serialize],
      deserialize: [Function: deserialize]
    },
    s: {
      id: 0,
      options: [Object: null prototype],
      seedlist: [Array],
      state: 'connected',
      description: [TopologyDescription],
      serverSelectionTimeoutMS: 30000,
      heartbeatFrequencyMS: 10000,
      minHeartbeatFrequencyMS: 500,
      servers: [Map],
      sessionPool: [ServerSessionPool],
      sessions: Set(0) {},
      credentials: [MongoCredentials],
      clusterTime: [Object],
      connectionTimers: Set(0) {},
      detectShardedTopology: [Function: detectShardedTopology],
      detectSrvRecords: [Function: detectSrvRecords],
      srvPoller: [SrvPoller]
    },
    [Symbol(kCapture)]: false,
    [Symbol(waitQueue)]: Denque {
      _head: 0,
      _tail: 0,
      _capacity: undefined,
      _capacityMask: 3,
      _list: [Array]
    }
  },
  [Symbol(namespace)]: MongoDBNamespace { db: 'iptv', collection: 'tv' },
  [Symbol(documents)]: [],
  [Symbol(initialized)]: false,
  [Symbol(closed)]: false,
  [Symbol(killed)]: false,
  [Symbol(options)]: {
    readPreference: ReadPreference {
      mode: 'primary',
      tags: undefined,
      hedge: undefined,
      maxStalenessSeconds: undefined,
      minWireVersion: undefined
    },
    fieldsAsRaw: {},
    promoteValues: true,
    promoteBuffers: false,
    promoteLongs: true,
    serializeFunctions: false,
    ignoreUndefined: false,
    bsonRegExp: false,
    raw: false,
    writeConcern: WriteConcern { w: 'majority' },
    readPreference: ReadPreference {
      mode: 'primary',
      tags: undefined,
      hedge: undefined,
      maxStalenessSeconds: undefined,
      minWireVersion: undefined
    }
  }
}
  • Вопрос задан
  • 47 просмотров
Решения вопроса 1
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы