Document Id along with other data

n1ql

#1

My document id
“id”: “b2b_portal_4861dfbf-6ed3-4f37-90b5-f86df2afbdb3” and my document data is
{
“email”: "arafatr@gmail.com",
“password”: “12345689”,
“table_type”: “b2b_portal”
}

How can i get my document data with document id


#2

META().id gives document id

SELECT MEAT(d).id, d.* FROM default AS d 
WHERE ......;

#3

Hi @arafat15-1830. If you have the document id then also consider using the standard key-value SDK over N1QL, as it’ll be faster. If you’re on Java then it looks like this:

    JsonDocument doc = bucket.get("b2b_portal_4861dfbf-6ed3-4f37-90b5-f86df2afbdb3");
    String email = doc.content().getString("email");
    String id = doc.id();
    // etc...

Please see the SDK docs here for more info (if you’re using a different language, use the drop-down at the top.)


#4

SELECT meta().id, * FROM catalog where email ="arafatr@gmail.com" AND table_type = “b2b_portal” ; by this query i get the document with id but when i write this query from node it only returns the {
“email”: "arafatr@gmail.com",
“password”: “12345689”,
“table_type”: “b2b_portal”
}

but not the document id .I am using node js.