Is it possible to have mutliple templates defined for a single Notefile

Hi,

recently I was wondering if the design of Note Templates allows for multiple templates to be assigned for a given Notefile.
My initial picture of note rejection mechanism on a templated notefile, was that more than one template can be provided in order to expand the range of possible note’ body json structures.

On the other hand, is it possible to somehow omit a whole JSON object, within a given note body?
Since, given how note structure tracks omitempty property, for what is considered a default value of a field’ subtype, this could allow a sender to work with more variety.
I can imagine specifying this property for a given JSON object either when registering a template, or just some kind of a rule across the all note.add ( body field) requests.

But, the whole purpose of templates, as I understand it, was to guide a design where each note would be relatively fixed length (or at least define an upper bound), in order to guarantee robust storage allocation.

Also, given this paragraph is a bit ambiguous:


Are the old templates accessible or applied somehow? Is the Notecard API implying that we need to erase previous templates for a given file, with note.template request where file is specified, but body left out.
Also, was ‘numerous Notefile templates (>25)’ meant for a given file at the give time, or for a given file across all time (but only one template active on that file), or for any notefiles across all time (or one time).

Hi @Jakov,

I’m not sure if you saw my initial reply, but I just deleted it as it was actually incorrect. To be clear, each Notefile can only be associated with one template. Now, within that one template you do have some flexibility. For example, you can create a relatively complicated body that includes all sorts of data types (including arrays), but then only include the data you need in subsequent note.add requests.

{
  "req": "note.template",
  "file": "readings.qo",
  "port": 50,
  "body": {
    "new_vals": true,
    "temperature": 14.1,
    "humidity": 11,
    "pump_state": "4",
    "array_vals": [true, 14.1, 11, "4"]
  }
}

However, what you can’t do is use a JSON object in a templated Note. You’d be better served by using a standard (non-templated) Note.

Thanks,
Rob

Thank you Rob,

That makes sense, I’d just need your advice for managing these three usage scenarios

  • “I want this Note to be synced regardless of RAT in use (cellular, Wi-Fi, or satellite).”
  • “I only want this (large) Note to be synced when using non-NTN communications (e.g. cellular or Wi-Fi).”
  • “I only want this (small) Note to be synced when using NTN communications (e.g. satellite).”

It is recommended to keep them managed in separate notefiles?

Hi @Jakov,

I would definitely use separate Notefiles for these scenarios, especially because:

  1. You can have separate templates for each (and you must use templated Notes for NTN communications anyway).
  2. There are significant data storage and cellular data usage advantages when using templated Notefiles.
  3. It also gives you some additional flexibility for routing (you can choose to route/not route data by Notefile name).

Thanks,
Rob

1 Like

Right, but I was thinking along the line of using one notefile but change schema just-in-time preemptively before transitioning between the given three scenarios mentioned above.
But that just seems like a wasteful anti-pattern.

Hi @Jakov,

Yeah don’t do that! Templates are meant to be created once and only once for a given Notefile. When you create additional templates for the same Notefile, you’re effectively wasting resources by allocating additional storage unnecessarily on the Notecard.

Rob

1 Like