简体   繁体   English

如何在golang中获取mongodb的转储并还原它

[英]how to get dump of mongodb in golang and restore it

I am using MongoDB as database and mgo and mogo libraries in Go. 我在Go中将MongoDB用作数据库以及mgo和mogo库。 I want to get a dump of my DB and restore it to write some utility methods to write unit test. 我想获取我的数据库的转储并将其还原以编写一些实用程序方法来编写单元测试。 my purpose is to dump the database then test my functions and after all restore it. 我的目的是转储数据库,然后测试我的功能,然后将其全部还原。 Can you help me how can I do it using mogo or mgo? 您能帮我如何使用mogo或mgo吗?

There are mock libraries available which can be used to mock databases when creating test cases to check the database.No needs to dump database and run test cases on that. 有可用的模拟库可用于在创建测试用例以检查数据库时模拟数据库,无需转储数据库并在其上运行测试用例。 And then Restore to get your original data. 然后还原以获取原始数据。 Try this library 试试这个图书馆

It is installing some packages for mongo db mock test cases 它正在为mongo db模拟测试用例安装一些软件包

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM