Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-31973

sometimes response doesn't display from the child collection if I connect to child collection inside parent collection.

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL
    • Hide
      Unable to find source-code formatter for language: node.js. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      const viewAllReviews = (req, res, next) => {
          ParentTable.findOneById(req.params.id)
              .then((resp) => {
                  const r = resp;
                  if (resp.user_ratings.length > 0) {
                      for (let i = 0; i < resp.user_ratings.length; i += 1) {
                          ChildTable.findOneById(resp.user_ratings[i].userId)
                              .then((users) => {
                                  r.user_ratings[i] = {
                                      ratings: resp.user_ratings[i].ratings,
                                      comments: resp.user_ratings[i].comments,
                                      comment_added: resp.user_ratings[i].comment_added,
                                      comment_updated: resp.user_ratings[i].comment_updated,
                                      commentId: resp.user_ratings[i].commentId,
                                      userId: resp.user_ratings[i].userId,
      
                                      // data from user collection
                                      username: users.username,
                                      displayname: users.displayname,
                                      profilepicture: users.profilepicture
                                  };
      
                                  if (i === resp.user_ratings.length - 1) {
                                      res.result(resp.user_ratings, 200, next);
                                  }
                              });
                      }
                  } else {
                      res.result(r.user_ratings, 200, next);
                  }
              })
              .catch(e => next(e));
      };
      

      the result from user collection doesn't display sometimes. If I refresh again then it displays

      Show
      Unable to find source-code formatter for language: node.js. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml const viewAllReviews = (req, res, next) => { ParentTable.findOneById(req.params.id) .then((resp) => { const r = resp; if (resp.user_ratings.length > 0) { for (let i = 0; i < resp.user_ratings.length; i += 1) { ChildTable.findOneById(resp.user_ratings[i].userId) .then((users) => { r.user_ratings[i] = { ratings: resp.user_ratings[i].ratings, comments: resp.user_ratings[i].comments, comment_added: resp.user_ratings[i].comment_added, comment_updated: resp.user_ratings[i].comment_updated, commentId: resp.user_ratings[i].commentId, userId: resp.user_ratings[i].userId, // data from user collection username: users.username, displayname: users.displayname, profilepicture: users.profilepicture }; if (i === resp.user_ratings.length - 1) { res.result(resp.user_ratings, 200, next); } }); } } else { res.result(r.user_ratings, 200, next); } }) . catch (e => next(e)); }; the result from user collection doesn't display sometimes. If I refresh again then it displays

      Hi,

      I am trying to display data from tow collection. I have connected to child(user) collection inside parent collection and fetching some basic details of user from user(child) collection and displaying along with parent collection data.
      The problem is sometimes data from user collection doesn't display. If I refresh the page again then it displays. sometimes displays, sometimes doesn't display. and if I refresh it displays. Checked in postman as well by calling API but same problem. sometimes response not displaying from user collection. But parent collection data displays every time.
      Can you please tell me how can I fix this.
      Please give me solution for this.

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            ashraf.seventech@gmail.com Ashraf Kamal
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: