Subscribe to this thread
Home - General / All posts - Row Updated Unix Time
514 post(s)
#11-Feb-24 22:11

Is there a more efficient way to do this, rather than make a DataHash() of the entire row's values?

I would like to add a computed field "updated_at" to a table in Release 9 which

  • auto-updates with the "current" unix epoch time integer when any value in any field in the row changes, except
  • not when the table schema is altered.

The approach I had thought best (I need UUID here rather than the mfd_id INT64 for other design reasons):

  • Add a computed UUID field to the table with UUIDMakeNewRef(99), and a btree unique not null index on that field, then
  • Add a computed FLOAT64 field "row_hash" to the table having an inline C# function which iterates over every field in the record, CASTING each value to string and building a concatenated string comprised of every field in the row (including the computed UUID field but excluding any other computed fields or fields where the value is NULL) and returns the result of Manifold's DataHash(mylong_concatenation), and then
  • Add a computed field "updated_at" which uses inline C# function and field parameter (as in the documentation Example - Using a Script to Show Date Modified) to call System.DateTimeOffset.Now.ToUnixTimeSeconds()

Thank you in advance for any advice.

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.