Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the latest MongoDB Driver #358

Closed
wants to merge 6 commits into from
Closed

Added support for the latest MongoDB Driver #358

wants to merge 6 commits into from

Conversation

JoCat
Copy link

@JoCat JoCat commented Nov 26, 2020

Starting from version 3 of MongoDB Driver, you need to separately specify the connection address and select the table using client.db('db_name')

@ririko5834
Copy link

works good, but please fix also this

(node:549) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:549) DeprecationWarning: collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead.

@JoCat
Copy link
Author

JoCat commented Dec 3, 2020

I'm not good at Mongo yet, but I sort of fixed

@ririko5834
Copy link

Ty, Also are haste entries auto removed after 30 days from latest visit from mongodb?

@JoCat
Copy link
Author

JoCat commented Dec 4, 2020

Haven't tested yet, just recently installed 😏

@JoCat
Copy link
Author

JoCat commented Jan 6, 2021

Ty, Also are haste entries auto removed after 30 days from latest visit from mongodb?

Doesn't seem to work

@ririko5834
Copy link

@JoCat Yes it does not work for me, I setuped expire in config.json file. Can someone fix the problem?

@JoCat
Copy link
Author

JoCat commented Jan 10, 2021

@ririko5834 Honestly, I have no idea how it works

@xlnd47
Copy link

xlnd47 commented Jan 24, 2021

@JoCat ConnectionName is not working correctly but I fixed it with this

const MongoDocumentStore = function (options) {
    this.expire = options.expire;
    this.connectionName = process.env.DATABASE_NAME || options.connectionName;
    this.connectionUrl = `${process.env.DATABASE_URL || options.connectionUrl}/${this.connectionName}`;
};

@xlnd47
Copy link

xlnd47 commented Jan 24, 2021

@ririko5834 did you insert it under storage inside the config file like this?

"storage": {
    "type": "mongo",
    "connectionUrl": "mongodb+srv://username:password@cluster0.xxxx.mongodb.net",
    "connectionName": "dbname",
    "expire": 2592000
},

@JoCat
Copy link
Author

JoCat commented Jan 25, 2021

i am using the following config:

"storage": {
  "type": "mongodb",
  "connectionUrl": "mongodb://localhost:27017",
  "connectionName": "haste"
}

Everything works for me correctly

@JoCat
Copy link
Author

JoCat commented Jan 25, 2021

Ty, Also are haste entries auto removed after 30 days from latest visit from mongodb?

Doesn't seem to work

@ririko5834 I am an idiot, I did not register expire in the config 🤣

@katsumag katsumag mentioned this pull request Jun 26, 2021
@anondev-sudo
Copy link

Make sure to close the connection after reading/writing data in mongodb.

It generates large amount of connections
image
image

Then you cant view or make new pastes when you reach 500 connections limit:
image

@JoCat Can you PR this?

@JoCat
Copy link
Author

JoCat commented Dec 21, 2021

Can you PR this?

Yes, I can see in a couple of hours, I'll just be at home

By the way, I suspected something like this because when my local MongoDB shut down and restarted, the RAM was immediately full (seems to be due to a lot of connections) and I had to restart the Hastebin server

@JoCat
Copy link
Author

JoCat commented Dec 21, 2021

@anondev-sudo i fixed the error with the connection limit, now the connection is closed after executing the request

The only thing that I do not like this approach a little. Callback hell is crazy. I tried to rewrite the class here (https://github.com/JoCat/haste-server/commit/84338fd81db05b941f4b09f1120cdbd8efa79176), although I need to modify the code a little more

@vpn
Copy link

vpn commented Jan 6, 2022

Thanks for that @JoCat, your fix worked for me.

@github-actions
Copy link

github-actions bot commented Mar 8, 2022

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Mar 8, 2022
@filipechagas filipechagas added triage and removed stale labels Mar 8, 2022
@JoCat JoCat closed this by deleting the head repository Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants