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

IS_MONGODB_CLOUD_URL turn into boolen #29

Merged
merged 3 commits into from Feb 27, 2022

Conversation

tusheer
Copy link
Contributor

@tusheer tusheer commented Feb 26, 2022

In connectWithDb function when we collect IS_MONGODB_CLOUD_URL from env it gives us a value as a string, So if we check is it false or true it always returns true. So I turn it into a boolean using the Boolean function.

@foyzulkarim
Copy link
Owner

Hi @tusheer bro. Thanks for your pull request.
However, it seems this fix actually won't fix the problem. :)
image

@foyzulkarim
Copy link
Owner

@tusheer bro you can try to use JSON.parse function to evaluate the variable.
image

Nice find. I appreciate your efforts

@@ -1,6 +1,6 @@
const mongoose = require("mongoose");
require('dotenv').config()
const isMongoDbUrl = process.env.IS_MONGODB_CLOUD_URL;
const isMongoDbUrl = Boolean(process.env.IS_MONGODB_CLOUD_URL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use JSON.parse please

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Bhaiya for your correction. This is really inspiring when I can communicate with you at least through the code. Happy coding Bhaiya.

@@ -1,6 +1,6 @@
const mongoose = require("mongoose");
require('dotenv').config()
const isMongoDbUrl = Boolean(process.env.IS_MONGODB_CLOUD_URL);
const isMongoDbUrl = JSON.parse(process.env.IS_MONGODB_CLOUD_URL);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if IS_MONGODB_CLOUD_URL is undefined then we will face the same problem. Let's try JSON.parse(a ? a : 'false') algo for now. 😎
Thanks 👍

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@foyzulkarim foyzulkarim merged commit 7914bea into foyzulkarim:main Feb 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants