Guest User

Google Cloud Query

a guest
Sep 28th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.02 KB | None | 0 0
  1. /**
  2.  * My full data. It's purely made up for an example.
  3.  */
  4. [
  5.     {
  6.         "userId": 10,
  7.         "timestamp": 1000
  8.     },
  9.     {
  10.         "userId": 10,
  11.         "timestamp": 500
  12.     },
  13.     {
  14.         "userId": 5,
  15.         "timestamp": 10
  16.     },
  17.     {
  18.         "userId": 5,
  19.         "timestamp": 1500
  20.     },
  21.     {
  22.         "userId": 5,
  23.         "timestamp": 50
  24.     }
  25. ]
  26.  
  27. /**
  28.  * What I want to recieve
  29.  *
  30.  * Notice the userId is unique and only the largest timestamp is retrieved
  31.  */
  32. [
  33.     {
  34.         "userId": 10,
  35.         "timestamp": 1000
  36.     },
  37.     // {
  38.     //  "userId": 10,
  39.     //  "timestamp": 500
  40.     // },
  41.     // {
  42.     //  "userId": 5,
  43.     //  "timestamp": 10
  44.     // },
  45.     {
  46.         "userId": 5,
  47.         "timestamp": 1500
  48.     },
  49.     // {
  50.     //  "userId": 5,
  51.     //  "timestamp": 50
  52.     // }
  53. ]
  54.  
  55. /**
  56.  * What I actually receive with my query shown in the stackoverflow question
  57.  */
  58. [
  59.     {
  60.         "userId": 10,
  61.         "timestamp": 1000
  62.     },
  63.     {
  64.         "userId": 10,
  65.         "timestamp": 500
  66.     },
  67.     // {
  68.     //  "userId": 5,
  69.     //  "timestamp": 10
  70.     // },
  71.     // {
  72.     //  "userId": 5,
  73.     //  "timestamp": 1500
  74.     // },
  75.     // {
  76.     //  "userId": 5,
  77.     //  "timestamp": 50
  78.     // }
  79. ]
Add Comment
Please, Sign In to add comment