Note that there are some explanatory texts on larger screens.

plurals
  1. POReplicate only documents where {'public':true} in MongoDB
    primarykey
    data
    text
    <p>I have the following network/mongodb setup: </p> <ul> <li><p>1 primary mongodb database (<code>10.0.0.1</code>, not accessible from the Internet) - contains private info in collection A, and a collection B, with documents created by a trusted user. At any point in time, a user can mark any document in collection B as 'public', which changes its property from <code>{'public':false}</code> to <code>{'public':true}</code>.</p></li> <li><p>1 public mongodb database (<code>10.0.0.2</code>, runs a webserver accessible from the Internet via a reverse proxy) - does not contain collection A, but should contain all documents marked as 'public' from collection B. This machine will serve those public documents to users outside the network.</p></li> </ul> <p>How would I set up mongodb so that when a document in the primary database (<code>10.0.0.1</code>) is updated with <code>{'public':true}</code>, it gets replicated to the public mongodb database (<code>10.0.0.2</code>)? </p> <p><strong>Other details:</strong></p> <ul> <li>I'm using the PHP driver </li> <li>The documents are small, max 2KB </li> <li>The load on these servers will probably never exceed 10 concurrent users</li> <li>Eventual consistency is ok, up to a few minutes, but I'd like to know what my options are. </li> </ul> <hr> <p>So, just to reiterate, here's a use case:</p> <blockquote> <p>John VPNs into our private network, opens <code>http://10.0.0.1/</code>, creates a document (call it <code>D2</code>), marks it as private. John then views an older document, <code>D1</code>, and decides to make it public, by clicking the 'Make public' button. The server automagically makes the document available on the public server <code>example.com</code> (public IP <code>x.y.z.w</code>, internal IP <code>10.0.0.2</code>).</p> <p>John sends an e-mail to Sarah and asks her to read document D1 (the one that was made public). Sarah goes to <code>http://example.com</code> and is able to read <code>D1</code>, but never sees <code>D2</code>.</p> </blockquote> <p>My goal is to achieve this without having to manually write scripts to synchronize those two databases. I suspect it should be possible, but I can't figure it out from what I've read about MongoDB replication.</p> <p>I welcome any advice.</p> <p>Thank you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload