Skip to content

Instantly share code, notes, and snippets.

@asimmon
Created March 25, 2023 16:57
Show Gist options
  • Save asimmon/8b6988b68c9f855138767c9e91cfb7e5 to your computer and use it in GitHub Desktop.
Save asimmon/8b6988b68c9f855138767c9e91cfb7e5 to your computer and use it in GitHub Desktop.
EphemeralMongo blog post example
var options = new MongoRunnerOptions
{
UseSingleNodeReplicaSet = true,
StandardOuputLogger = Console.WriteLine,
StandardErrorLogger = Console.WriteLine,
};
using (var runner = MongoRunner.Run(options))
{
var database = new MongoClient(runner.ConnectionString).GetDatabase("mydb");
database.CreateCollection("people");
runner.Export("mydb", "people", "/path/to/mydb-people.json");
runner.Import("mydb", "people", "/path/to/mydb-people.json");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment