For the third week, I start with familiarizing myself with carrying out create, read, update and delete operations on the CouchDB database. This involves sending HTTP requests using the Poco library. I learnt to use the “If-Match” header to retrieve a document’s revision so that I can perform update operations more easily, instead of having to retrieve the revision each time I want to update a document. Also when sending new requests, it is good to reuse the request that has been already set up, to save memory.

Next I familiarized myself with the nlohmann/json library. Things I learnt from reading the documentation include creating JSON objects and arrays, and serialization/deserialization. A useful definition I found was that serialization/deserialization are “basic mechanisms to flatten object(s) into a one-dimensional stream of bits, and to turn that stream of bits back into the original object(s)”. I then created JSON objects in a document on the database. The initial problem I had was setting the content length of the response body, as I had difficulty setting the number of bytes of the JSON object. With Dr Shawn’s suggestion, I converted the JSON object to a string first so the number of bytes is obtained easily.

My project involves listening to changes to a certain group of documents. I am specifically listening for a change in the “status” field of the event documents. For now I have used GET, along with a set of filters, to read the status of events. I do need to listen for changes though, and I plan to use longpoll for that, which is a type of feed that listens to changes.

I am also tasked with studying a pre-written ServerApplication, then modifying it for my project. I look forward to making further progress on the project next week.


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.