fastify / fastify-mongodb

Fastify MongoDB connection plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fastify.mongo.client.topology // TS2339: Property topology does not exist on type MongoClient

Bugs5382 opened this issue · comments

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Fastify version

4.26.1

Plugin version

8.0.0

Node.js version

20.11

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

14.4

Description

The decorator can see to "client," and then the topology is missing.

image

Even though TypeScript is reporting it as "not defined", which is odd, it should, the code runs without issue.

return fastify.mongo.client.topology.isConnected()

Steps to Reproduce

I am using this as part of a health check:

fastify.addHealthCheck('mongodb', async () => {
      return fastify.mongo.client.topology.isConnected()
})

this

Expected Behavior

It should be valid and give proper documentation of other available options. I think this might be due to the package of the MongoDB client, which was raised a long time ago.

commented

I am closing this issue because mongodb exclude the types from release.
Which means topology is something internal and they don't want to expose.

https://github.com/mongodb/node-mongodb-native/blob/2348548495ce5257ea2379f41e2693851e1bfb5d/src/mongo_client.ts#L347-L354

image