there is something I wonder: In my map reduce function, can I take "parent" property as a variable ? Like that :
function (doc, meta) {
var key,value;
if(doc.type == "mainForums" && doc.parent == **VAR**){
key = [doc.type,doc.id]
value = {Id : doc.id, Title : doc.title, Description : doc.description, Parent: doc.parent, HasChild : doc.hasChild, Level : doc.level, ImageUrl : "http://icon.donanimhaber.com/mobile-forum-icons/" + doc.iconPath, AvarageColor: doc.avarageColor, RepMode : doc.repMode, iconPath : doc.iconPath, MessageCountThisWeek : doc.messageCountThisWeek, TopicCountThisWeek : doc.topicCountThisWeek}
emit(key, value);
}
}
Since I'm creating map reduce function on the couchbase console, I don't get how can I add a variable to this function. I'm doing the mapping part on MVC, as below:
var tempForum = new Forum
{
Id = item.Id,
Title = item.Title,
Description = item.Description,
HasChild = item.HasChild,
Level = item.Level,
iconPath = item.iconPath,
Parent = item.Parent,
IsFavorite = item.IsFavorite,
TopicCountThisWeek = item.TopicCountThisWeek,
MessageCountThisWeek = item.MessageCountThisWeek,
RepMode = item.RepMode,
ForumExtra = item.ForumExtra
}
to print the json on the screen properly. I should take what mobile(android) programmer gives me as a variable, lets say 4, and bring him parent=4 docs from the sync_gateway. Or should android programmer do that map reduce thing?
Maybe I should forget about views and use only N1QL on a situation like that? Because I'm able to do it with N1QL but i want to do it with views too, because I may need views later. I'm not really sure what is the best and I'm really confused.
Thanks a lot.