Answer the question
In order to leave comments, you need to log in
How can you increment a value in Mongo?
Hello!
Happy New Year to you!
Pilot project on Meteor. News aggregator.
Database structure on Mongo:
{_id: channelId,
title: channelTitle,
pubDate: channelPubdate,
items: [ // массив объектов новостей
{title: newsTitle, desc: newsDescription, link: newsLink, pubDate: Date, clicks: 0},
{},
{},
...] }
Template.newsItems.events({
"click .news-body-custom": function(e, t) {
var iframe = document.getElementsByName("news-iframe")[0];
iframe.src = this.link;
var target = e.target;
while (target.className !== "news-body-custom") {
target = target.parentNode;
}
var clicks = target.getElementsByClassName("clicks")[0];
clicks.innerHTML = +clicks.innerHTML + 1;
debugger;
News.update({ _id: Session.get("channelId"), items: { $elemMatch: { link: this.link }}}, {$inc: {clicks: 1 }});
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question