-
-
Notifications
You must be signed in to change notification settings - Fork 2
More Mongo
You can connect to MongoDB using the database
constructor in the hive.mongo
adapter.
const hive = require('hive-db');
const {database} = hive.mongo;
const db = new database("mongodb+srv://wyvern:thebestbot@cluster0.67lsz.mongodb.net", "JSON", {useUnique: True})
The database constructor initializes the mongodb connection using the uri. The JSON parameter helps it recognize the data if stored in json. It can be left default if you don't want to actually use JSON, it won't harm. The UseUnique param on the other hand asks if the data should be checked for its uniqueness, i.e., every data in each and every key is different from each other. And that's pretty much it for the definition of the connection module.
Please do not remove the {} from the database initialization, this will result in an error. The {}, shows that database is a constructor and not a normal constant or variable.
There are ping or latency issues with mongodb, which is not an issue of hive-db's. Its something with your database uri.
If your planning to use mongodb localhost with hive-db it'll work fine, although there are some incidents where you don't require your port, just the address. You can try it with a port as well, of course this is a hit and try case.
hive-db guide