Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

2
How to find a group total of paginated results
Post Body

Hi,

I'm very new to Mongo and coming from a mySQL background so please excuse any ignorance on best practice and all that.

I am trying to query my collection of jobs and send back paginated results based on searchText and location.

Within the object being returned I also need to summarise the locations column and contractType column. I need these to be as close to the below as possible but I can't work out how to actually get a sub-query of the locations and contract types of the jobs found before the limit was applied.

Any help is hugely appreciated.

Cheers Leigh

    PostJob.find(
        {
            'descriptions': { $regex: searchText, $options: 'i' },
            'location': { $regex: location, $options: 'i' }
        }
        )
    .sort({'updatedAt': -1})
    .skip(page)
    .limit(limit)
    .then(postjobs => {
        jobData.docs = postjobs;
        jobData.limit = limit;
        jobData.page = page;
        jobData.contractTypeTotals = {
          temp: 100,
          permanent: 50
        };
        jobData.locations = [
          {city: London, total: 20},
          {city: Manchester, total: 20},
          {city: Glasgow, total: 110}
        ];
      return res.status(200).json(jobData);
    })
    .catch(next);

Author
Account Strength
90%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
691
Link Karma
293
Comment Karma
398
Profile updated: 2 days ago
Posts updated: 1 month ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
7 years ago