socketio / socket.io-website

Socket.IO website and blog
https://socket.io
318 stars 668 forks source link

Outdated MongoDB Connection Example in Documentation #417

Closed num13ru closed 10 months ago

num13ru commented 10 months ago

Description:

The current documentation for the mongo-adapter on the Socket.io website https://socket.io/docs/v4/mongo-adapter/ has an outdated example that is not compatible with the recent versions of Mongoose.

Based on the Mongoose migration guide from 5.x to 6.x https://mongoosejs.com/docs/6.x/docs/migrating_to_6.html#no-more-deprecation-warning-options, the options useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported.

However, the example in the Socket.io documentation still uses useUnifiedTopology: true which results in a TypeScript error:

"Argument of type '{ useUnifiedTopology: boolean; }' is not assignable to parameter of type 'MongoClientOptions'.
Object literal may only specify known properties, and 'useUnifiedTopology' does not exist in type 'MongoClientOptions'."

Steps to Reproduce:

  1. Follow the example code provided in the documentation.

Expected Result: The code should run without any errors and establish a connection with the MongoDB server.

Actual Result: A TypeScript error is thrown as mentioned above.

Suggested Fix: Update the documentation to remove the deprecated options. The corrected connection string would look like:

const mongoClient = new MongoClient("mongodb://localhost:27017/?replicaSet=rs0");

Thank you for looking into this. The outdated documentation could potentially lead to confusion for developers integrating the mongo-adapter into their projects.

darrachequesne commented 10 months ago

You are absolutely right, thanks for the heads-up!

This should be fixed by https://github.com/socketio/socket.io-website/commit/fc8edb76889d20a40431d6d87d71a04185b9c894.