FTM, medicine with breastfeeding

I had a c section and the pain is unbearable I was prescribed oxycodone, but I’m breast feeding well this effect my newborn baby? Why would my doctor give me this if I’m breast feeding? I’m scared now that it’ll affect my baby in any way.