0

I am inserting images to the mongodb through c++ API as below :

   bsoncxx::document::value document = bsoncxx::builder::basic::make_document
                            (kvp("userId", "xZcuQet3QMmS7Q2yc"),
                             kvp("source",encoded_png),
                             kvp("createdAt",bsoncxx::types::b_date(std::chrono::system_clock::now()))
                            );
                    bsoncxx::stdx::optional<mongocxx::result::insert_one> result =
                            coll.insert_one(document.view());

Also I am pulling realtime from MeteorJs . I encountered there is a few seconds (5 - 7 sec) delay.

Is it possible that c++ code not flushing the insert ?

How I can do realtime insert with flushing immediately available ?

Is that possible?

Rahibe Meryem
  • 269
  • 3
  • 14

2 Answers2

1

Is it possible that c++ code not flushing the insert ?

You can check MongoDB collection whether the document is inserted properly or not. You can use MongoDB Shell or other MongoDB Managers (e.g. RoboMongo) for this regard.

How I can do realtime insert with flushing immediately available ?

You can Publish a publication from the server side of Meteor application and subscribe to it to get the published data immediately.

Mostafiz Rahman
  • 8,169
  • 7
  • 57
  • 74
1

Change detection is done using oplog tailing. This isn't done in development mode. Updates made from Meteor code trigger updates immediately, but mongo updates from an external source such as Mongo shell or your C++ code take some time to come through, which is what you are seeing.

In production, if you have the oplog tailing set up properly you shouldn't see the delay.

Mikkel
  • 7,693
  • 3
  • 17
  • 31