How N1QL get doc ID?

I use N1QL to select list of results, but seem to be that the results not shown ID of these documents.

So how do use N1QL query that the result includes doc.id?

select meta(t).id from t;

6 Likes

Thanks @geraldss.
It’s done.

How make order with this query please.
thx

SELECT META(t).id
FROM t
ORDER BY META(t).id;
1 Like

thx Geral
(from Orange Sophia Antipolis 18/02/16 :wink: )

1 Like

Salut Marwen! :relaxed:

Salut Gerald
Thx for again for the presentation in February and for your answer
:slight_smile: :slight_smile:

1 Like

Hi, I have a little question about it
its possible get in a single response all the document and the id?

SELECT META().id, * FROM app WHERE type='example'

The response is something like:

[
  {
    "app": {
      "disabled": false,
      "email": "juan.ramirez@test.ai",
      "first_name": "ivan",
      "role": "admin",
      "type": "userprofile"
    },
    "id": "documentidxxx"
  }
]

I would like get the response:

[
  {
      "id": "documentidxxx"
      "disabled": false,
      "email": "juan.ramirez@test.ai",
      "first_name": "ivan",
      "role": "admin",
      "type": "userprofile"
  }
]

It is possible?

Thnks

SELECT META().id,  app.* 
FROM app  WHERE type="example";

Note: If there is already id filed inside the document it will be overwritten. You need to alias to new one.

2 Likes