Note that there are some explanatory texts on larger screens.

plurals
  1. POfindOne use in mapreduce mongodb
    primarykey
    data
    text
    <p>I want to use <code>findOne</code> in map reduce. What is wrong with my code? My error is:</p> <p>Command 'mapreduce' failed: exception: map invoke failed: JS Error: TypeError: user has no properties nofile_b:3 (response: { "errmsg" : "exception: map invoke failed: JS Error: TypeError: user has no properties nofile_b:3", "code" : 9014, "ok" : 0.0 })</p> <pre><code>string map = @" function() { var movie = this; var user = db.users.findOne({UserId : parseInt(movie.UserId)}); emit( movie.UserId, {Name:user.Name}); }"; string reduce = @" function(key, values) { var result =values; return result; }"; string finalize = @" function(key, value){ return value; }"; </code></pre> <p>Under c# code</p> <pre><code>var collection = database.GetCollection("movies"); var options = new MapReduceOptionsBuilder(); options.SetFinalize(finalize); options.SetOutput(MapReduceOutput.Inline); var results = collection.MapReduce(map, reduce, options); lbResultList.Items.Clear(); foreach (var result in results.GetResults()) { lbResultList.Items.Add(result.ToJson()); } </code></pre> <p>I solve my problem map function change </p> <pre><code>function () { var user = db.users.find({UserId:this.UserId}); var userName =''; var userSurName =''; user.forEach(function(u) { userName = u.Name; userSurName = u.SurName; }); emit( this._id, {title: this.Title,category:this.Category,UserName: userName,UserSurName: userSurName} ); </code></pre> <p>}</p> <p>I think it is not logical,like sub query this solve. What can I do this case?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload