Q: why delete = 1 of metadata, but can curl from database?

HI,

I inspect data from web console N1QL as follows:

SELECT META().id,* FROM kitchen
WHERE meta().xattrs._sync.history.deleted[0]=1
LIMIT 1000

the statements result like as follows:

},
{
“id”: “Handover.def3825e-b7a1-477b-8612-a82ac24d64af”,
“kitchen”: {}
},
{
“id”: “Handover.f47722fd-958c-48ab-83b9-6e6a8717aa30”,
“kitchen”: {}
},
{
“id”: “Member.00ed69e8-1ddc-41c1-80e0-03ebf1ecb16a”,
“kitchen”: {}
},
{
“id”: “Member.00edc35d-1ddd-41c1-80e0-03eacbbfb169”,
“kitchen”: {}
},
{
“id”: “Member.010b5ded-1ede-40cf-8c7f-f60667a20241”,
“kitchen”: {
“birthday”: “”,
“cardNo”: “000008”,
“channelId”: “733d2f51”,
“chargePresentTotal”: 0,
“chargeTotal”: 0,
“className”: “Member”,
“createdTime”: “2017-06-30 14:10”,
“hangupConsumed”: 0,
“hangupInfo”: “”,
“hangupTotal”: 0,
“invoice”: false,
“location”: “徽州人家”,
“mobile”: “”,
“name”: “陈婧”,
“operator”: “Employee.62d46e48-843a-43d7-aae0-434250cb443d”,
“promotionId”: “Promotion.c7529d96-d8b3-4012-b581-9639a4fbdd8a”,
“valid”: true
}
},
{
“id”: “Member.01629e85-0dba-4256-8184-fbcd87bb7c81”,
“kitchen”: {}
},
{
“id”: “Member.0276052c-1b5f-4d26-a702-227f2938eb77”,
“kitchen”: {}
},

I want use this statement to filter documents tomb, a lot of documents looks match the filter, the documents body is empty . but a few of documents still have body contents. like as follows:

[root@k8s-master1 ~]# curl http://localhost:4985/kitchen/Company.af0a9555-b66d-4551-999b-3356aa4a9298
{“_id”:“Company.af0a9555-b66d-4551-999b-3356aa4a9298”,“_rev”:“3-21840a75bcd2fdcbcd8dd08b1eb5a08e”,“channelId”:“733d2f51”,“className”:“Company”,“dataType”:“BaseData”,“mobile”:“13075368763”,“pointName”:“徽州人家”,“pwd”:“$2a$10$8ZJP1aEqLGDy3qz9ZCAMAOVnVbDbX2mxTLhwDvFYVvFMo6EK3qsOq”}[root@k8s-master1 ~]#
[root@k8s-master1 ~]#
[root@k8s-master1 ~]#
[root@k8s-master1 ~]# curl http://localhost:4985/kitchen/_raw/Company.af0a9555-b66d-4551-999b-3356aa4a9298
{“_sync”:{“rev”:“3-21840a75bcd2fdcbcd8dd08b1eb5a08e”,“sequence”:42443,“recent_sequences”:[40612,42441,42443],“history”:{“revs”:[“1-6169ea69cff843decd69002a90f21af7”,“2-966926570b96c7b795338fffb15f88ff”,“3-21840a75bcd2fdcbcd8dd08b1eb5a08e”],“parents”:[-1,0,1],“deleted”:[1],“channels”:[[“733d2f51”],null,[“733d2f51”]]},“channels”:{“733d2f51”:null},“access”:{“733d2f51”:{“733d2f51”:42443,“733d2f51_casher”:42443}},“cas”:“0x00004bb831b89715”,“value_crc32c”:“0x49248e0f”,“time_saved”:“2019-04-22T14:31:59.954590178+08:00”},“channelId”:“733d2f51”,“className”:“Company”,“dataType”:“BaseData”,“mobile”:“13075368763”,“pointName”:“徽州人家”,“pwd”:“$2a$10$8ZJP1aEqLGDy3qz9ZCAMAOVnVbDbX2mxTLhwDvFYVvFMo6EK3qsOq”}[root@k8s-master1 ~]#

why the deleted is 1, but still curl get this documents from sg?
can I use above n1ql statements filter deleted documents?

when I browse document from web console ui, displayed a lot of documents with empty contents as follows:

are those documents is deleted document tomb?
the couchbase lite still synced those files.

maybe I used method is error. when the documents not for useing, I use logical deleted from sg or golang sdk. Will cause such a problem, right?

the couchbase lite after the test has been used for a while, the application become very slow. and the sync very slow.

when I ensure the documents never need, must I calll purge from sg or sdk?

my env is:
cb: 6.0.1
lite: 2.5
sg: 2.5

if I mistake before, haven’t purge not need documents, how can I filter and delete those documents tombo?

thanks!

angular

try this

SELECT META().id,* FROM kitchen
WHERE meta().xattrs._sync.history.deleted[0]=1 AND meta().xattrs.`$document`.deleted == false
LIMIT 1000
1 Like

HI @vsr1,

thanks for your reply.
use your N1QL script still get have body documents. the document xattrs contents is:

{
“meta”: {
“id”: “Member.0c1f469a-959b-461c-9ecf-ef24f566f7a4”,
“rev”: “24-15919a69fbb300000000000000000000”,
“expiration”: 0,
“flags”: 0,
“type”: “json”
},
“xattrs”: {
“_sync”: {
“rev”: “3-f369c506438fc618059f3357df87e630”,
“sequence”: 16253,
“recent_sequences”: [
14293,
15738,
16253
],
“history”: {
“revs”: [
“1-1f57cb9dde76bbe14049a8d58a43530d”,
“2-fdd6334d0df8ed7f22cfb63f2d57908f”,
“3-f369c506438fc618059f3357df87e630”
],
“parents”: [
-1,
0,
1
],
“deleted”: [
1
],
“channels”: [
[
“733d2f51”
],
null,
[
“733d2f51”
]
]
},
“channels”: {
“733d2f51”: null
},
“cas”: “0x0000b3fb699a9115”,
“value_crc32c”: “0xf2cd75c6”,
“time_saved”: “2019-04-02T16:18:46.403052094+08:00”
}
}
}

the document is:

{
“birthday”: “”,
“cardNo”: “000070”,
“channelId”: “733d2f51”,
“chargePresentTotal”: 0,
“chargeTotal”: 0,
“className”: “Member”,
“createdTime”: “2017-09-06 17:08”,
“hangupConsumed”: 0,
“hangupInfo”: “”,
“hangupTotal”: 0,
“invoice”: false,
“location”: “徽州人家”,
“mobile”: “”,
“name”: “李娟”,
“operator”: “Employee.62d46e48-843a-43d7-aae0-434250cb443d”,
“promotionId”: “Promotion.c7529d96-d8b3-4012-b581-9639a4fbdd8a”,
“valid”: true
}

I only want get the documents tomb. that means the documents has logic delete from bucket.
But I don’t know what these attributes mean:

may you pointing me what the means of property as follows :

    "parents": [
      -1,
      0,
      1
    ],
    "deleted": [
      1
    ],

I kewn if the deleted array contain 1 that the file has logical deleted. but I see the deleted array contain [-1, 1, 2], is this per revision correspond status?
what the parents property?

thanks
angular

HI @vsr1,

may you take a little time for my question? my bucket have a lot of documents with empty body, when I deleted a documents form couchbase lite use DB.delete(ID), then I query this document ID, the web console ui result that document is not exist. and I browse the documents, haven’t see any documents with empty body. but if I flush the bucket, then resync data form couchbase lite, the bucket appear a lot of documents with empty body. how can I do?
thanks!