// Example of how to connect to a Mongo DB server with SSL, in this case a connection via ssh port forwarding to a DocumentDB server
// cluster: `dp ssh develop publishing 1 -p 27017:develop-docdb-cluster.cluster-cpviojtnaxsj.eu-west-1.docdb.amazonaws.com:27017`
Example of how to connect to a Mongo DB server with SSL, in this case a connection via ssh port forwarding to a DocumentDB server
cluster: `dp ssh develop publishing 1 -p 27017:develop-docdb-cluster.cluster-cpviojtnaxsj.eu-west-1.docdb.amazonaws.com:27017`
// Example of how to connect to a Mongo DB server with SSL in this case a connection via ssh port forwarding to a DocumentDB server // cluster : ` dp ssh develop publishing 1 - p 27017 : develop - docdb - cluster . cluster - cpviojtnaxsj . eu - west - 1 . docdb . amazonaws . com : 27017 `
func ExampleOpen() {
	connectionConfig := &mongoDriver.MongoConnectionConfig{
		ClusterEndpoint: "localhost:27017",
		Database:        "recipes",
		Collection:      "recipes",
		Username:        "XXX- username for recipe-api for authentication",
		Password:        "XXX - the password for the above username",
		ConnectTimeoutInSeconds:       5,
		QueryTimeoutInSeconds:         5,
		IsStrongReadConcernEnabled:    true,
		IsWriteConcernMajorityEnabled: true,
		TLSConnectionConfig: mongoDriver.TLSConnectionConfig{
			IsSSL:              true,
			VerifyCert:         true,
			CACertChain:        "./test/data/rds-combined-ca-bundle.pem",
			RealHostnameForSSH: "develop-docdb-cluster.cluster-cpviojtnaxsj.eu-west-1.docdb.amazonaws.com",
		},
	}
	mongoDB, err := mongoDriver.Open(connectionConfig)
	if err != nil {
	}
	ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
	defer cancel()
	_, _ = mongoDB.GetConfiguredCollection().Insert(ctx, bson.M{"recipe field": "field value"})
}
func ExampleOpen ( ) { connectionConfig := & mongoDriver . MongoConnectionConfig { ClusterEndpoint : " " , Database : " " , Collection : " " , Username : " " , Password : " " , ConnectTimeoutInSeconds : 5 , QueryTimeoutInSeconds : 5 , IsStrongReadConcernEnabled : true , IsWriteConcernMajorityEnabled : true , TLSConnectionConfig : mongoDriver . TLSConnectionConfig { IsSSL : true , VerifyCert : true , CACertChain : " " , RealHostnameForSSH : " " , } , } mongoDB , err := mongoDriver . Open ( connectionConfig ) if err != nil { } ctx , cancel := context . WithTimeout ( context . Background ( ) , 1 * time . Second ) defer cancel ( ) _ , _ = mongoDB . GetConfiguredCollection ( ) . Insert ( ctx , bson . M { " " : " " } ) }
Example of how to connect to a Mongo DB server with SSL, in this case a connection via ssh port forwarding to a DocumentDB server
cluster: `dp ssh develop publishing 1 -p 27017:develop-docdb-cluster.cluster-cpviojtnaxsj.eu-west-1.docdb.amazonaws.com:27017`
Example of how to connect to a Mongo DB server with SSL in this case a connection via ssh port forwarding to a DocumentDB server cluster : ` dp ssh develop publishing 1 - p 27017 : develop - docdb - cluster . cluster - cpviojtnaxsj . eu - west - 1 . docdb . amazonaws . com : 27017 `
// log error, cannot use mongo db // Can now work with the mongo db