Reputation: 57
I'm making a .list() call on cloudantDB using node.JS and I have the following return
"success": true,
"data": {
"status": true,
"res": {
"total_rows": 1,
"offset": 0,
"rows": [
{
"id": "012022",
"key": "012022",
"value": {
"rev": "1-0d48e71b8a774b394c2b6f380e600cde"
},
"doc": {
"_id": "012022",
"_rev": "1-0d48e71b8a774b394c2b6f380e600cde",
"year": 2022,
"month": "01",
"count": 0
}
}]
}
}
I'm making the call this way
CloudantConnection.use("history_metric")
.list({
include_docs: true,
limit: 12,
})
.then((res) => {
response = { status: true, res };
})
.catch((error) => {
response = { status: false, error };
});
I would like to know if there is any way to not return the _id and _rev in the DOC, I wanted a return like this
"success": true,
"data": {
"status": true,
"res": {
"total_rows": 1,
"offset": 0,
"rows": [
{
"id": "012022",
"key": "012022",
"value": {
"rev": "1-0d48e71b8a774b394c2b6f380e600cde"
},
"doc": {
"year": 2022,
"month": "01",
"count": 0
}
}]
}
}
Upvotes: 0
Views: 141
Reputation: 3737
The list()
call maps to the Cloudant api endpoint _all_docs and so is beholden to returning what it returns, which includes both the id and rev id for each returned row. This is typically what you want: if you do any subsequent processing on the documents returned, you'd need to refer to these ids.
If you want to discard these, for example, if sending the data onwards to something else that doesn't expect them, you need to filter them out yourself on your side.
Upvotes: 2