I'm trying to add a 'views' number on my page by incrementing the value every time someone visits the page.
I have a object like this:
{
_id: "55da051afe08e73168fc7aeb",
url: "https://www.youtube.com/watch?v=eUdM9vrCbow",
title: "Django Unchained",
embedUrl: "https://www.youtube.com/embed/eUdM9vrCbow",
__v: 0,
downvotes: 0,
upvotes: 0,
views: 0,
created_on: "2015-08-24T13:37:33.951Z",
desc: "With the help of his mentor, a slave-turned-bounty hunter sets out to rescue his wife from a brutal Mississippi plantation owner."
}
I'm retrieving this object via AngularJS's '.one()' method:
var movie = Movie.one($routeParams.id);
The goal is to increment this value. At the moment I'm doing it like this:
movie.views++;
movie.put();
But that doesn't work and just gives me a null value, while this does work:
movie.views = 10;
movie.put();
What am I doing wrong?
movie.views = movie.views + 1;movieobject? That would explain why direct assignment of a number works, but incrementing (a null) doesn't.movie, if that doesnt work too, movie doesnt get loaded so everything is undefined and incrementing doesnt work but setting it to 10 does.