func (driver *MongoDBDriver) Get(id string) (*shared.Paste, error) {
	collection := driver.client.Database(driver.database).Collection(driver.collection)
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()
	filter := bson.M{"_id": id}
	result := collection.FindOne(ctx, filter)
	err := result.Err()
	if err != nil {
		if err == mongo.ErrNoDocuments {
			return nil, nil
		}
		return nil, err
	}
	paste := new(shared.Paste)
	err = result.Decode(paste)
	if err != nil {
		return nil, err
	}
	return paste, nil
}
Get loads a paste
package mongodb
import (
	"context"
	"time"
	"github.com/lus/pasty/internal/config"
	"github.com/lus/pasty/internal/shared"
	"go.mongodb.org/mongo-driver/bson"
	"go.mongodb.org/mongo-driver/mongo"
	"go.mongodb.org/mongo-driver/mongo/options"
	"go.mongodb.org/mongo-driver/mongo/readpref"
)
type MongoDBDriver struct {
	client     *mongo.Client
	database   string
	collection string
}
func (driver *MongoDBDriver) Initialize() error {
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	client, err := mongo.Connect(ctx, options.Client().ApplyURI(config.Current.MongoDB.DSN))
	if err != nil {
		return err
	}
	err = client.Ping(ctx, readpref.Primary())
	if err != nil {
		return err
	}
	driver.client = client
	driver.database = config.Current.MongoDB.Database
	driver.collection = config.Current.MongoDB.Collection
	return nil
}
func (driver *MongoDBDriver) Terminate() error {
	return driver.client.Disconnect(context.TODO())
}
func (driver *MongoDBDriver) ListIDs() ([]string, error) {
	collection := driver.client.Database(driver.database).Collection(driver.collection)
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()
	result, err := collection.Find(ctx, bson.M{})
	if err != nil {
		return nil, err
	}
	var pasteSlice []shared.Paste
	err = result.All(ctx, &pasteSlice)
	if err != nil {
		return nil, err
	}
	var ids []string
	for _, paste := range pasteSlice {
		ids = append(ids, paste.ID)
	}
	return ids, nil
}