How to access doctype from website script?

I have a website script that I use to count to number a clicks on a button on the webpage. I wrote the script to get the original value of the field and increment it by one each time the button is clicked. but checking the console, it says that
" Uncaught TypeError: frappe.db is undefined"
I searched but found nothing, any solutions to this problem?