Saturday, 13 May 2017

How can I sort data on Mongodb

Here is data from MongoDB

{
  "urls" : {
    "beauty-credit" : {
      "count" : 1,
      "keyword" : "beauty credit",
      "last_res" : 152,
      "last_sea" : "Sat May 13 2017 15:16:41 GMT+0700 (SE Asia Standard Time)",
      "url_site" : "beauty-credit"
    },
    "etude" : {
      "count" : 2,
      "keyword" : "etude",
      "last_res" : 1048,
      "last_sea" : "Sat May 13 2017 15:16:38 GMT+0700 (SE Asia Standard Time)",
      "url_site" : "etude"
    },
    "skinfood" : {
      "count" : 2,
      "keyword" : "skinfood",
      "last_res" : 478,
      "last_sea" : "Sat May 13 2017 15:16:45 GMT+0700 (SE Asia Standard Time)",
      "url_site" : "skinfood"
    }
  }
}

and Here is my code. Now I filter only last_res > 10

const urls_kws = Object.keys(result)
                    .filter(key => result[key].last_res > 10)

How can I sort data by "count"? Also how can I show only 30 rows?



via Moomoo Soso

No comments:

Post a Comment