[SERVER-31974] sometimes response doesn't display from the child collection if I connect to child collection inside parent collection. Created: 15/Nov/17  Updated: 15/Nov/17  Resolved: 15/Nov/17

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Ashraf Kamal Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-31973 sometimes response doesn't display fr... Closed
Operating System: ALL
Steps To Reproduce:

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

Participants:

 Description   

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.



 Comments   
Comment by Ashraf Kamal [ 15/Nov/17 ]

sorry,, this ticket is duplicate of SERVER-31973
could not delete so commented here

Generated at Thu Feb 08 04:28:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.