Append sensor data into document in Couchbase database

We are a group of people writing a bachelor-project about storing sensor data into a noSQL-database, and we have chosen couchbase for this.

We want to store quite a few data in the same document, one document per day, per sensor, and we want to append new sensor data witch comes in every minute. But unforunatly, we are not able to append new data into existing document without overwriting the existing data.

The structure for the documents should be like:

DocumentID: Sensor + date, ie: KitchenTemperature20180227

{
  "topic": "Kitchen/Temp",
  "type": "temperature",
  "unit": "DegC"
  "20180227130400": [
    {
      "data": "24"
    }
  ],
..............
  "20180227130500": [
    {
      "data": "25"
    }
  ],
}

We are all new to couchbase and NoSql-databases, but eager to learn and understand how we the best way should implemet this. We’ve tried upsert, insert and update commands, but they all overwrite the existing document or won’t execute because the document already exists. As you can see, we have some top-level information, like topic, type, unit. The rest should be data coming in every minute and appended to the existing document.

Help on how to proceed would be greatly appriciated.

For information we use Python SDK for inserting/appending to documents, and .NET for fetching data.

Best regards, Kenneth

For info, this should be used for time-series representation of sensor-data.

You can use subdocument API, for example like this:

bucket.mutate_in('customer123', SD.array_append('purchases.complete', 777))
# purchases.complete is now [339, 976, 442, 666, 777]

More info at: