//FindOne returns one document from the specified collection
//Returns a bson.M that needs to be decoded ( bson.M.decode() )
//You need to check if the result.Err() is mongo.ErrNoDocuments if it returns Err
FindOne returns one document from the specified collection
Returns a bson.M that needs to be decoded ( bson.M.decode() )
You need to check if the result.Err() is mongo.ErrNoDocuments if it returns Err
// FindOne returns one document from the specified collection // Returns a bson . M that needs to be decoded ( bson . M . decode () ) // You need to check if the result . Err () is mongo . ErrNoDocuments if it returns Err
func (db *DB) FindOne(collectionName string, filter bson.M) (*mongo.SingleResult, error) {
	collection := db.Client.Database(db.DatabaseName).Collection(collectionName)
	result := collection.FindOne(db.BasicContext, filter)
	if result.Err() != nil {
		return nil, result.Err()
	}
	return result, nil
}
func ( db * DB ) FindOne ( collectionName string , filter bson . M ) ( * mongo . SingleResult , error ) { collection := db . Client . Database ( db . DatabaseName ) . Collection ( collectionName ) result := collection . FindOne ( db . BasicContext , filter ) if result . Err ( ) != nil { return nil , result . Err ( ) } return result , nil }
FindOne returns one document from the specified collection
Returns a bson.M that needs to be decoded ( bson.M.decode() )
You need to check if the result.Err() is mongo.ErrNoDocuments if it returns Err
FindOne returns one document from the specified collection Returns a bson . M that needs to be decoded ( bson . M . decode () ) You need to check if the result . Err () is mongo . ErrNoDocuments if it returns Err