Reputation: 338
I'm new to go
and MongoDB
. I want to connect to MongoDB with GORM in go-lang
. after a lot of searches, I still can't do it.
Upvotes: 8
Views: 20170
Reputation: 417652
In short: you can't. GORM is created for relational databases, and MongoDB is not a relational but a NoSQL database.
And you can't even use GORM with all SQL databases, the officially supported list at the moment is: MySQL, PostgreSQL, SQLite3 and SQL Server, although you can "easily" add support for other SQL servers by writing GORM dialects for them. But that's the end of it. Adding support for MongoDB would require more work than what your gain would be.
Consider using the official MongoDB driver which is quite mature now. Or if using GORM is a must for you, you must choose another (not MongoDB, preferably one of the above listed supported) database.
Upvotes: 29