Problem
I have a database of recordings recordingsDB
sent from a client application which uses pouchDB. Each recording is it's own document. e.g.
{
"_id": "2019-10-20T04:51:22.744Z",
"_rev": "1-53e73be51ea76f96e3cfde2de1502439",
"locale": "en",
"_attachments": {
"recordings.webm": {
"content_type": "audio/webm; codecs=opus",
...
}
}
}
The client application has a single user clientUser
(so anyone accessing the website becomes clientUser
). The client user can therefor write to recordingsDB
but also read from recordingsDB
which is not desirable because they can read any recordings from recordingsDB
.
I went down "write only" database road and came across this answer from 2011. I'm wondering how to implement that.
Idea
So what I believe would work is if my recordingsDB
would replicate all of the recordings to a masterRecordingsDB
where the clientUser
is no longer a member. After each document from the recordingsDB
is copied to the masterRecordingsDB
it would be deleted.
Setup
I have configured a replicator which copies the content from recordingsDB to masterRecordingsDB.
{
"_id": "recordings_to_master_recordings",
"_rev": "3-a6fa84dd89c2ec037353c17f65b4c765",
"continuous": true,
"source": {
"url": "http://localhost:5984/recordings",
"headers": {
"Authorization": "Basic YWRtaW46cGFzc3dvcmQ="
}
},
"target": {
"url": "http://localhost:5984/master_recordings",
"headers": {
"Authorization": "Basic YWRtaW46cGFzc3dvcmQ="
}
},
"user_ctx": {
"name": "admin",
"roles": [
"_admin"
]
},
"owner": "admin"
}
How can I delete the items in recordingsDB after each successful replication?