What are Note Templates and Why Should I Use Them


What are Note Templates?

Note Templates are a description of a prescribed data structure with pre-set sizes for data added to the body of Notes in a Notefile.

A Note Template names each field of the Note Body. Each named field must also describe the datatype of the field value.

For more information about how to create Note Templates, see the note.template request documentation.

Why should you use them?

Note Templates provide Notecard with way to store future Notes added to a Notefile as fixed-length binary records.

Using this type of storage enables:

  • Increased storage capability

  • Faster data syncs

With increased storage, you can enqueue more data on the Notecard, enabling longer periods between syncs with the cloud. This can help preserve power usage, by reducing the number of syncs.

Faster data syncs result in less time to sync data with Notehub. Once a connection is established to Notehub, more data can be moved much more quickly with fewer computing resources. The reduced connection time also helps conserve power usage.

When should you use Note Templates?

Most Notecard applications can and should use Note Templates to queue data.

Sensor data is ideal, as the number of recorded elements and data types are probably fixed.

For example, storing temperature data, each point will consist of a numeric value for temperature. Knowing this information prior to queuing each measurement value on the Notecard to store and transmit the data as raw bytes rather than including the JSON data structure for each data point.

When should you avoid Note Templates?

If the structure and size of the stored data elements cannot be known a priori, the data structure must change frequently, then Note Templates may not be a good fit.

Changing Note Templates on the fly

If the structure of a Note Template needs to change to accommodate a change the JSON data structure, issue a new note.template request to the Notecard.

For example, imagine your application supports dynamically adding temperature sensors. You do not want to lose the information from previous temperature measurements from the existing sensors, but you want to accommodate data from the additional sensor in the same Notefile. In this case, reissue the Note Template request and include an additional field for the new temperature sensor.

However, if the data structure is changing every data point, then this probably is not worth the overhead.

See Also: