I don't know what the laws are where you live but I would guess he had no right to search your backpack without your consent. To me, what you're describing is police aggression and you must always push back against any such aggression. You should not have submitted to the search. The legal system is adversarial and you must protect yourself from the very first moment you are in any way involved with it.
To quote James Duane from his book You Have the Right to Remain Innocent: "Nobody of sound mind can dispute that there is something fundamentally wrong, and intrinsically corrupt, about a legal system that encourages police officers and prosecutors to do everything in their power to persuade you and your children (no matter how young or old) to 'do the right thing' and talk - when they tell their own children the exact opposite."
The book: https://www.amazon.com/You-Have-Right-Remain-Innocent/dp/150...
Get dozens of book recommendations delivered straight to your inbox every Thursday.