I have been working on a project for a url shortener, where I am trying to increment views
every time someone hit that api or someone make a get
request. I don't know what is getting wrong but the views are just incrementing for once only.
Here's the code I wrote to increment the views every time a get request is made.
I do not know what is going wrong, I have already searched through lot of forums, stack overflow, articles already asked problems.
Note -
- The default value of
views
is0
, here is the value inpost
request. - Distinct users, generated by are dummy values as of now.
- Mongoose Schema Link - link
- I am creating this project with nodejs, expressjs, mongodb(database), mongoose(orm), pugjs(view engine).
- Project Link : link
Here's the file tree
├── LICENSE
├── README.md
├── client
│ ├── assets
│ │ ├── bg.svg
│ │ ├── favicon
│ │ │ └── favicon.ico
│ │ └── fonts
│ │ ├── Apercu\ Medium.woff
│ │ ├── Apercu\ Mono.woff
│ │ └── Apercu_Regular.woff
│ ├── css
│ │ └── style.css
│ ├── index.html
│ └── js
│ └── script.js
├── index.js
├── models
│ ├── admin_model.js
│ └── urlshorten.js
├── package-lock.json
├── package.json
├── routes
│ ├── admin.js
│ ├── auth.js
│ ├── custom.js
│ ├── stats.js
│ └── urlShorten.js
├── static
│ ├── css
│ │ └── style.css
│ ├── favicon.ico
│ ├── fonts
│ │ └── Inter-Regular.woff
│ └── urlshort.gif
└── views
├── index.pug
└── script.js