github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/state/mongo.go (about)

     1  // Copyright 2015 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package state
     5  
     6  import (
     7  	jujutxn "github.com/juju/txn/v3"
     8  
     9  	"github.com/juju/juju/mongo"
    10  )
    11  
    12  // environMongo implements state/lease.Mongo to expose environ-filtered mongo
    13  // capabilities to the sub-packages (e.g. lease, macaroonstorage).
    14  type environMongo struct {
    15  	state *State
    16  }
    17  
    18  // GetCollection is part of the lease.Mongo interface.
    19  func (m *environMongo) GetCollection(name string) (mongo.Collection, func()) {
    20  	return m.state.db().GetCollection(name)
    21  }
    22  
    23  // RunTransaction is part of the lease.Mongo interface.
    24  func (m *environMongo) RunTransaction(buildTxn jujutxn.TransactionSource) error {
    25  	return m.state.db().Run(buildTxn)
    26  }