Update

Add/Update specific fields in single/multiple documents.

The Story So Far...

Kenny has joined the manufacturing department as the Safety Officer in-charge, and all employee entries are now correctly recorded in the HRMS.

It is now annual appraisal time, and Stan has been working extra hard the last few weeks to stay on the good books of Eric. Eric has taken note of this and has decided to promote Stan to the rank of Senior Plant Manager. Kyle is not too happy about this, since he too has been going the extra mile, hoping to bag that promotion. Alas, he failed to make his efforts adequately visible to Eric. Bummer, but Kyle has learnt a few tricks from observing Stan, and holds out hope for next time.

We need to update Stan's role in the HRMS. However, we note that it is not enough to just update the role, although RecallGraph will track history for the change - we need to also somehow keep track of the effective date from which his promotion is valid. In real-world scenarios, this may not be the same as the time of entry of the new information, which may be done preemptively or retroactively.

circle-exclamation

To keep track of the effective promotion date, we will start marking each write operation with a user-defined timestamp, which we will call valid_from. Note that this can only work for creates and updates, and not for delete operations.

circle-exclamation

Entering Data

In the Swagger console locate the tab with the button. The collection parameter should be set to employees and the body should contain only the new and the changed content of the entity.

circle-info

One of _key or _id would still need to be present.

Request Body:

{ "_key": "44794453", "role": "Senior Plant Manager", "valid_from": "2020-05-07" }

Response:

{
  "_id": "employees/44794453",
  "_key": "44794453",
  "_rev": "_acx_g1C--_",
  "_oldRev": "_aclQHSa---"
}

End Result

circle-check

Last updated