Layer7 API Management

Expand all | Collapse all

[URGENT] does LAC provide automatic update to created_at & updated_at fields of table records?

  • 1.  [URGENT] does LAC provide automatic update to created_at & updated_at fields of table records?

    Posted Oct 24, 2017 04:50 AM

    What happens in the some of the application for example Rails applications, Rails automatically manage the created_at and updated_at field of the records. We don't need to take care of them explicitly. 

     

    does LAC has this kind of feature for all tables of a database? what I know is we can write a rule for every table and update the created_at field if its a new record and update the updated_at field of the table if there is an update in the existing table but as you know this is not an easy task to write a rule for every table we do have in the database. Please suggest any good way of doing it?#



  • 2.  Re: [URGENT] does LAC provide automatic update to created_at & updated_at fields of table records?
    Best Answer

    Broadcom Employee
    Posted Nov 02, 2017 09:07 PM

    The most efficient way to do this is at the database level. If you use MySQL, you can just use the TIMESTAMP data type. If you use something else (SQL Server, Postgres, DB2...), you can use that database's mechanism, for instance for DB2: 

     

    create table schemaName.tableName (cod int, update_ts timestamp not null generated always for each row on update as row change timestamp

     

    That said, you can definitely create a formula or an event. In a future release, we will probably introduce the concept of global events, which will allow you to do this in a single rule.

     

    In the meantime, you could try using a request event to automatically set the timestamp fields. It's not as clean, but you could do it in a single request event.