Simple SQL query to Couchbase -


i have following document:

{    "postid": "message_2d73b43390041e868694a85a65e47a09d50f019c180e93baacc454488f67a411_1375457942227",    "userid": "user_2d73b43390041e868694a85a65e47a09d50f019c180e93baacc454488f67a411",    "post_message": "test",    "attachments": {        "images": [        ],        "audio": [        ],        "videos": [        ]     },    "timestamp": 1375457942227,     "followers": [     ],    "follow": 0,    "reporters": [    ],    "report": 0,    "rerayz": 0,    "mtype": "post" } 

i following query:

select * posts users in ("user_1", "user_2", "user_3") order_by timestamp limit 20

i did following , pass multiple ?keys=["user_1", "user_2", etc] . how can results sorted timestamp in order 20 first?

function (doc, meta) {   if(doc.mtype == "post") {     emit(doc.userid, doc.post_message);   } } 

any suggestions?

thanks.

i see 2 choices here (there more):

  1. emit time stamp instead of user id. loop through results , filter out users want using code instead of asking couchbase you. loop until have 20 matching records.

  2. you emit user id followed timestamp. search each user in turn , grab last 20 posts (each). put these in sort of array or structure , sort them (using code) timestap. grab first 20 entries in array (which contains 60 items if have 3 users) , have need.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -