HI @househippo,
Thank you for your prompt reply.
I get the document from sg _raw endpoint:
curl http://localhost:4985/test1/_raw/MsgGoods.11a9d08a-03eb-4cf4-9203-bf2baa3f0dd6
{“_sync”:{“rev”:“2-7ad33dc7a80dc26a4e74e535ffb030d6a1b6371c”,“flags”:1,“sequence”:49,“recent_sequences”:[49],“history”:{“revs”:[“1-e98dc20d95db2dd4d8e7853c4ea9de8d03d01661”,“2-7ad33dc7a80dc26a4e74e535ffb030d6a1b6371c”],“parents”:[-1,0],“deleted”:[1],“channels”:[null,null]},“cas”:“0x00000a83f357a815”,“value_crc32c”:“0x297bd0aa”,“tombstoned_at”:1560593974,“time_saved”:“2019-06-15T10:19:34.27080908Z”}}
this document as to revision:
I get the first revision from sg:
curl http://localhost:4985/test1/MsgGoods.11a9d08a-03eb-4cf4-9203-bf2baa3f0dd6?rev=1-e98dc20d95db2dd4d8e7853c4ea9de8d03d01661
{“error”:“not_found”,“reason”:“missing”}
get the second revision:
curl http://localhost:4985/test1/MsgGoods.11a9d08a-03eb-4cf4-9203-bf2baa3f0dd6?rev=2-7ad33dc7a80dc26a4e74e535ffb030d6a1b6371c
{“_deleted”:true,“_id”:“MsgGoods.11a9d08a-03eb-4cf4-9203-bf2baa3f0dd6”,“_rev”:“2-7ad33dc7a80dc26a4e74e535ffb030d6a1b6371c”}
the first revision already can’t fetch. the second revision _deleted
is true.
I also suspect the CBL push those documents with empty body to SG then store in CB SERVER.
my sync gateway function
as follows:
function sync(doc, oldDoc) {
if (isRemoved()) {
return;
}
if (!isDelete()) {
validateNotEmpty("channelId", doc.channelId);
validateNotEmpty("className", doc.className);
if (isCreate()) {
if (!hasPrefix(doc._id, doc.className + ".")) {
throw ({ forbidden: "文档ID必须以对应的className作为前缀" });
}
}
}
/* Routing */
// Add doc to the user's channel.
if (isDelete()) {
channel(oldDoc.owner ? oldDoc.owner : oldDoc.channelId);
} else {
channel(doc.owner ? doc.owner : doc.channelId);
}
first: check the documents is remove from original channel. is removed, return and without any operate.
second: if is a not deleted document, validte the document.
third: if is a deleted document, according to the property of the document incorporate into channel.
please point where I make a mistake? or how can I filtered which the CBLITE document with empty body?
thanks very much
angular