Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:04:01+00:00 2026-06-08T10:04:01+00:00

I am trying to return the visits with minute greater than 12. My data

  • 0

I am trying to return the visits with minute greater than 12.

My data structure looks like this:

{ "_id" : "20120723/foobar/song/custom-cred",
  "live_daily_count" : 4,
  "metacontent" : { "date" : "20120723",
    "live_daily_statable_slug" : "custom-cred",
    "live_daily_statable_title" : "custom cred",
    "live_daily_statable_type" : "Song",
    "url" : "foobar/songs/custom-cred",
    "user_slug" : "foobar" },
  "visits" : [
    { "country_name" : "UK",
      "iso_two_letter_country_code" : "UK",
      "referer" : "http://localhost:3000/foobar/songs/no-title-with-space",
      "minute" : 12,
      "token_id" : "134300236111rcbmbmvv" },
    { "country_name" : "UK",
      "iso_two_letter_country_code" : "UK",
      "referer" : "http://localhost:3000/foobar/songs/no-title-with-space",
      "minute" : 13,
      "token_id" : "134300242111pjvkjjkf" },
    { "country_name" : "UK",
      "iso_two_letter_country_code" : "UK",
      "referer" : "http://localhost:3000/foobar/songs/no-title-with-space",
      "minute" : 13,
      "token_id" : "134300243511udbnqldm" }
  ]
}

I’m using the Mongodb Ruby driver. I tried with the following:

conn = Mongo::Connection.new
db   = conn['foobar_development']
cmd = {
  aggregate: 'live_daily_stats',
  pipeline: [
    { '$match' => { :_id => "20120723/foobar/song/custom-cred" } },
    { '$project' => {
      :visits => 1,
    } },
    { '$unwind' => '$visits' },
    # { '$group' => {
    #   :_id => '$_id'
    # } },
  ]
}

res = db.command(cmd)['result']

It now returns:

[
    [0] {
           "_id" => "20120723/foobar/song/custom-cred",
        "visits" => {
                                          "country_name" => "UK",
                           "iso_two_letter_country_code" => "UK",
                                               "referer" => "http://localhost:3000/foobar/songs/custom-cred",
                                                "minute" => 12,
                                              "token_id" => "134300236111rcbmbmvv"
        }
    },
    [1] {
           "_id" => "20120723/foobar/song/custom-cred",
        "visits" => {
                                          "country_name" => "UK",
                           "iso_two_letter_country_code" => "UK",
                                        "follower_class" => "non_follower",
                                               "referer" => "http://localhost:3000/foobar/songs/custom-cred",
                                                "minute" => 13,
                                              "token_id" => "134300242111pjvkjjkf"
        }
    },
    [2] {
           "_id" => "20120723/foobar/song/custom-cred",
        "visits" => {
                                          "country_name" => "UK",
                           "iso_two_letter_country_code" => "UK",
                                        "follower_class" => "non_follower",
                                               "referer" => "http://localhost:3000/foobar/songs/custom-cred",
                                                "minute" => 13,
                                              "token_id" => "134300243511udbnqldm"
        }
    }
]

How do I make sure the results only return the visits with minute greater than 12? Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:04:04+00:00Added an answer on June 8, 2026 at 10:04 am

    The $match pipeline element you use at the beginning can be used multiple times, including after your $unwind step.

    Once $unwind splits your visits array elements each into its own document you can add {$match:{“visits.minute”:{$gt:12}}} to the end of your pipeline and that should leave only visits you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to return a type from a fortran function. This is the code.
Im trying to return the value that a $ajax call returns, from a function
Im trying to return a SimpleQuery list that queries a single table and uses
Am trying to return the sum of each day of a week in mysql
I'm trying to return the most common elements in a list (statistical mode). Unfortunately
I'm trying to return a left child as a pointer I have template <typename
I am trying to return the value by using unix_timestamp function but it behaves
I am trying to return two json sets from java which each contain key/value
I am trying to return the values of the SECTION attribute of the INTRO
I'm trying to return use a JSON object with handlebars. Making a small todo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.