Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store Default date as Today's date column in Appmaker

Is there any configuration option available in Appmaker to Store Today's date as Default in a column record in Appmaker data source?

The current configuration directly provided an option to select date only, no option to write a script which can return me Today's date. Current option for choosing date


1 Answers

Unfortunately, App Maker doesn't provide such setting at this time, but there are at least two ways how you can do it:

  1. If you you are using Custom Cloud SQL instance you can make your table look like this:
CREATE TABLE foo (
    `creation_time`     DATETIME DEFAULT CURRENT_TIMESTAMP,
    `modification_time` DATETIME ON UPDATE CURRENT_TIMESTAMP
)
  1. In case you don't have direct access to the database you can add the following code in onBeforeCreate model event
record.CreatedOn = new Date();
like image 182
Pavel Shkleinik Avatar answered Dec 22 '25 18:12

Pavel Shkleinik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!