Sails.js default app fails to start with MongoDb - sails.js

I created a WebApp with sails new my-app and am trying to use mongodb as its database. I am running mongodb in docker and am able to connect to the database using GUI tools like MongoDB Compass. Using that tool I created todo_list database in mongo.
In the app, I changed default datastore in datastores.js to:
default: {
adapter: 'sails-mongo',
url: 'mongodb://root:rootpassword#localhost:27017/todo_list'
}
This connection string is correct as verified by using it to connect via MongoBD Compass.
When I run sails lift I get:
error: A hook (`orm`) failed to load!
error: Could not tear down the ORM hook. Error details: Error: Consistency violation: Attempting to tear down a datastore (`default`) which is not currently registered with this adapter. This is usually due to a race condition in userland code (e.g. attempting to tear down the same ORM instance more than once), or it could be due to a bug in this adapter. (If you get stumped, reach out at http://sailsjs.com/support.)
I saw this error raised in a few github issues, bu tteh answers were irrelevant to my situation. Any ideas what I could be doing wrong?

Related

Getting error while connecting dbt with postgres

I'm trying to connect my dbt project with postgres db.
I'm writing all the connecting credentials in profiles.yml but it is throwing below error when i am running dbt debug.
dbt was unable to connect to the specified database.
The database returned the following error:
type object 'PostgresConnectionManager' has no attribute 'retry_connection'
I'm unable to find solution anywhere.
dbt-core v1.2.0 has added retry_connection method in BaseConnectionManager to support the retry connection feature. If the adapter implements this method, it can't run on dbt-core v1.1.0. Try updating the adapter.

Error in connector: missing field `info` - Prisma Introspection (npx prisma db pull)

I have created an Express, Apollo GraphQL server which accepts requests and returns data from a MongoDB database via Prisma.
I have tested my application with a simple database from MongoDB Atlas and it all seems to work fine.
Now that I know everything works fine, I want to 'plug in' a MongoDB database which contains a lot of data already, located in my Azure portal (Cosmos DB).
I have changed the database connection string to point to this new database (a read only connection string) and now attempting to use the Introspection feature of Prisma (https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/mongodb/introspection-typescript-mongodb#introspecting-mongodb-with-prisma).
After running the npx prisma db pull --force command, I get the following error:
I can't figure out if this is an issue with my connection string, or something else.
I have also attempted to use the Read/ Write connection string but that doesn't seem to work either. I get the same error message.
There does not seem to be any information online regarding this error message other than this:
https://www.prisma.io/docs/reference/api-reference/error-reference#prismaclientvalidationerror
But I am unsure if this is at all related, because it seems to relate to creating a new record, rather than anything to do with introspection.

Spring application issues to connect to mongo db

Spring boot application.
MongoDb Database hosted on mongodb cloud.
Application propperties
#Database connection string
spring.data.mongodb.host=cluster0.mbdhj.mongodb.net
spring.data.mongodb.port=27017
spring.data.mongodb.database=sample_supplies
spring.data.mongodb.username=user
spring.data.mongodb.password=[my password]
spring.data.mongodb.auto-index-creation=true
Error
com.mongodb.MongoSocketException: No such host is known (cluster0.mbdhj.mongodb.net)
If I use the same host/port/user/password combination with MongoDb Compass, i can connect without issues.
If I use a cluster connection like this
spring.data.mongodb.host=cluster0-shard-00-02.mbdhj.mongodb.net
the application throws error
com.mongodb.MongoSocketReadException: Prematurely reached end of stream
I've opened the firewall, to accept any connection.
Analitics show some actions, but i still get error in Spring.
I was just following a single youtube tutorial. In their example this didn't cause any issue.
What am I doing wrong?
Should I write a class that connects via Java to the database?
Mongo cloud instances do not allow direct connection while debugging

Cant use mongodb after migrating parse database (using digital ocean migration tutorials)

I have never set up a server myself and I thought that seeing as I have to migrate my parse app I may as well have a go at it.
I have a database that I am moving from Parse to digital ocean. I have a droplet (ubuntu 14.0.4.4 x64) where I log in as a non root user with sudo privileges. I have followed this tutorial to get mongo set up on the droplet.
Then I have followed this tutorial step by step to get the example running on the droplet, which seems to work fine.
Now I am following this tutorial to migrate my existing data over. I have followed the tutorial step by step up to the part where I migrate the data from the parse.com browser. This seems to work fine as I receive the email from Parse saying that "Your Parse Data Migration for Is Ready To Be Finalised!".
The strange thing is, is that when I try to start mongo through terminal I get the error:
MongoDB shell version: 3.0.12
connecting to: test
2016-08-01T19:45:22.383-0400 I NETWORK DBClientCursor::init call() failed
2016-08-01T19:45:22.388-0400 E QUERY Error: DBClientBase::findN: transport error: 127.0.0.1:27017 ns: admin.$cmd query: { whatsmyuri: 1 }
at connect (src/mongo/shell/mongo.js:179:14)
at (connect):1:6 at src/mongo/shell/mongo.js:179
exception: connect failed
As I said I am new to using servers and am relying on these tutorials and hopefully help from the community here.
Thanks for your time

upgrade MongoHQ prevents sails-mongo to connect in prod env

I am using SailsJS 0.10.5.
I purchased a production MongoDB from Heroku and it created a variable with the new database url as follows:
mongodb://heroku:**password**#candidate.32.mongolayer.com:10485,candidate.13.mongolayer.com:10455/app123
However, when running the app in production environment only, the app fails to connect to database:
A hook (`session`) failed to load!
Could not load Connect session adapter :: connect-mongo
at new MongoStore (/app/node_modules/connect-mongo/lib/connect-mongo.js:115:19)
at validateDatabaseName (/app/node_modules/connect-mongo/node_modules/mongodb/lib
/mongodb/db.js:235:59)
at Hook.Session.initialize (/app/node_modules/sails/lib/hooks/session/index.js:20
5:37)
Error from adapter:
Error: database names cannot contain the character '.'
at new Db (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js
Note that when I copied the string locally and ran the app it worked perfectly.
I saw some workarounds suggest using Mongoose, but I want to stick to connect-mongo / sails-mongo
EDITED
I now managed to connect to the db by removing the replica set and simply add:
mongodb://heroku:**password**#candidate.32.mongolayer.com:10485/app123
However, a new error arrived:
Error: Error setting TTL index on collection : sessions
throw message;
at /app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/cursor.js:700
at commandHandler (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongo
at Cursor.close (/app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb
at /app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/db.js:1882:9
at Server.Base._callHandler (/app/node_modules/connect-mongo/node_modules/mongodb
at /app/node_modules/connect-mongo/node_modules/mongodb/lib/mongodb/connection/se
It keeps crashing the app.
Ideas?
Try to setup and download mongo-uri to parse the url automatically