Updating data/entities/bundles


#1

Is it possible to update any of the following data structures (and if so, how) ?

  1. Raw Data (updating existing fields of a record)
  2. Raw Data (adding new fields to an existing record)
  3. Entities (changing attributes of an existing entity)
  4. Contextual Bundles (changing the set of included entities, or the attributes included for these entities)

#2

Hi,

To answer your questions:

  1. Raw Data (updating existing fields of a record)

You can add new values associated with the same field and record:
http://hub-of-all-things.github.io/doc/?shell#data-value (under “Creating a Value within Field and Record”)

  1. Raw Data (adding new fields to an existing record)

You can add new fields into a table and then as above add values into a record

The endpoint is data/field, to which you POST a value along the lines of:

{
    "name": "fieldName",
    "tableId": 1
}

where tableId is an existing table you want to add the field to. To then add values see point above

  1. Entities (changing attributes of an existing entity)

Can add entities by adding properties (static and dynamic), as per docs, can not currently remove existing ones but this will be imlemented.

  1. Contextual Bundles (changing the set of included entities, or the attributes included for these entities)

Can add entities and attributes (can’t remove anything for security):

  • bundles/context/BUNDLE_ID/entitySelection, by posting an appropriate entity selection according to docs
  • bundles/context/BUNDLE_ID/entitySelection/ENTITY_SELECTION_ID/propertySelection, by posting an appropriate property selection according to docs

Hope this helps!

A.


#3

Thanks for your answer, I have now been able to add additional data values into existing records, both into new fields and into existing fields.

But this brings me to my next question: How do the dateCreated and lastUpdated fields work?

  1. I had been trying to manually set the two date fields during the POST to /data/value (so as to be able to link together “old” and “updated” value of an updated field in a record – they would have shared a “dateCreated” but differed in “lastUpdated”), but it seems the two fields are always set server-side to the current time (for both fields). Am I correct in concluding that these fields cannot be controlled by the caller?

  2. When adding a new value into an existing record, should that be having an effect on “lastUpdated” of the record itself?


#4

Currently both fields are set at creation time in almost all cases and are identical.

For the next release we are going to change “lastUpdated” field to be user(app)-defined, with the meaning of “when was the data last updated”. dateCreated will remain set by the system for when it was recorded in the HAT.