According to the docs after removing a document from a channel I should see a "\_removed":true
property (but it doesn’t say where… on the document perhaps?). It also doesn’t say how you remove a doc from a channel, I assume by just not calling the channel() function in my sync function?
And these docs say that “A document can be removed from a channel without being deleted” - which is exactly what I’m trying to achieve. It goes on to say that _"Sync Gateway’s changes feed includes one more revision of a document after it stops matching a channel. It adds a removed property to the entry where this happens.". From what I can tell this this doesn’t seem to be the case (see below).
Here’s my example.
The document is created, and then modified once. Here’s the sync-gateway log:
CRUD+: Invoking sync on doc "-amxUwtw61wfrH8BT4YGdkn" rev 1-6526909bb79ef534ca5c6a18f24369c1
CRUD: Doc "-amxUwtw61wfrH8BT4YGdkn" in channels "{ch_8a73ad6e-73f2-4bdb-a699-dd323ea9fb5e}"
CRUD: Stored doc "-amxUwtw61wfrH8BT4YGdkn" / "1-6526909bb79ef534ca5c6a18f24369c1"
Events+: Event queue worker sending event Document change event for doc id: -amxUwtw61wfrH8BT4YGdkn to: Webhook handler [http://macbookpro.local:8080/datr/webhook]
HTTP: #032: GET /sync_gateway/-amxUwtw61wfrH8BT4YGdkn (as admin)
HTTP: #033: PUT /sync_gateway/-amxUwtw61wfrH8BT4YGdkn (as admin)
CRUD+: Invoking sync on doc "-amxUwtw61wfrH8BT4YGdkn" rev 2-9e48e80b8e341cc47af667992a7f8c4c
CRUD+: Saving old revision "-amxUwtw61wfrH8BT4YGdkn" / "1-6526909bb79ef534ca5c6a18f24369c1" (300 bytes)
CRUD+: Backed up obsolete rev "-amxUwtw61wfrH8BT4YGdkn"/"1-6526909bb79ef534ca5c6a18f24369c1"
CRUD: Stored doc "-amxUwtw61wfrH8BT4YGdkn" / "2-9e48e80b8e341cc47af667992a7f8c4c"
Events+: Event queue worker sending event Document change event for doc id: -amxUwtw61wfrH8BT4YGdkn to: Webhook handler [http://macbookpro.local:8080/datr/webhook]
Cache: Received deduplicated #558237 for ("-amxUwtw61wfrH8BT4YGdkn" / "2-9e48e80b8e341cc47af667992a7f8c4c")
Cache: Received #558240 after 1530ms ("-amxUwtw61wfrH8BT4YGdkn" / "2-9e48e80b8e341cc47af667992a7f8c4c")
Cache: Received #558240 after 1530ms ("-amxUwtw61wfrH8BT4YGdkn" / "2-9e48e80b8e341cc47af667992a7f8c4c")
And at this point the clients _changes feed looks like this:
{
seq: 2057,
id: "-amxUwtw61wfrH8BT4YGdkn",
changes: [
{
rev: "2-9e48e80b8e341cc47af667992a7f8c4c"
}
]
}
A change is then made to the document that results in the sync-function not assigning it to any channel (by not calling the channel function at all). Here’s the sync-gateway log:
CRUD+: Invoking sync on doc "-amxUwtw61wfrH8BT4YGdkn" rev 3-e563f1c7edacef0aa6709861f6222acd
CRUD+: Saving old revision "-amxUwtw61wfrH8BT4YGdkn" / "2-9e48e80b8e341cc47af667992a7f8c4c" (314 bytes)
CRUD+: Backed up obsolete rev "-amxUwtw61wfrH8BT4YGdkn"/"2-9e48e80b8e341cc47af667992a7f8c4c"
CRUD: Doc "-amxUwtw61wfrH8BT4YGdkn" in channels "{}"
CRUD: Stored doc "-amxUwtw61wfrH8BT4YGdkn" / "3-e563f1c7edacef0aa6709861f6222acd"
Events+: Event queue worker sending event Document change event for doc id: -amxUwtw61wfrH8BT4YGdkn to: Webhook handler [http://macbookpro.local:8080/datr/webhook]
Cache: Received #558246 after 668ms ("-amxUwtw61wfrH8BT4YGdkn" / "3-e563f1c7edacef0aa6709861f6222acd")
This line make me think it has been removed from the channel:
CRUD: Doc "-amxUwtw61wfrH8BT4YGdkn" in channels "{}"
And at this point the clients _changes feed looks like this:
{
seq: 2062,
id: "-amxUwtw61wfrH8BT4YGdkn",
changes: [
{
rev: "3-e563f1c7edacef0aa6709861f6222acd"
}
]
}
…no removed property. And the document (on the device) looks like this:
http://localhost:5984/dbname/-amxUwtw61wfrH8BT4YGdkn =>
{
some_content: "blah",
_id: "-amxUwtw61wfrH8BT4YGdkn",
_rev: "3-e563f1c7edacef0aa6709861f6222acd"
}