When a date field is present in a document in a collection in RHMAP, altering the document manually in the data browser directly in studio causes the date field to be saved as type string instead of type Date. This can effect how the field is used in its app (e.g. When the field is used as search criteria during a database search).
Why
All Date formats are getting saved as Strings when a user edits a row in the databrowser.
How
Allow Date objects in the database to be transferred and displayed/saved in DateBrowser as javascript objects as follows:
{
$fhdate: "2018-10-10T11:54:12.366Z"
}
fh.db will check for $fhdate and save the field type as a Date in the database.
To read the fields from the database in the same format. The environment variable needs to be set in the app.
go to databrowser and click advanced editor on any row. Click raw and change the "when" key and value to "when": {"$fhdate", "2018-10-15T15:49:09.746Z"},. Click save
Check value types, the saved row should be a Date
Go to environment variables and add a new env var with the name SERIALISE_FH_DATES and value true.
All Dates in the databrowser should now show as Objects and can only be edited in advanced editor mode
Edit dates and check the value types to ensure they stay as Dates.
Checklist:
[X] Code has been tested locally by PR requester
[ ] Changes have been successfully verified by another team member
Jira link(s)
https://issues.jboss.org/browse/RHMAP-21771
What
When a date field is present in a document in a collection in RHMAP, altering the document manually in the data browser directly in studio causes the date field to be saved as type string instead of type Date. This can effect how the field is used in its app (e.g. When the field is used as search criteria during a database search).
Why
All Date formats are getting saved as Strings when a user edits a row in the databrowser.
How
Allow Date objects in the database to be transferred and displayed/saved in DateBrowser as javascript objects as follows:
fh.db will check for $fhdate and save the field type as a Date in the database.
To read the fields from the database in the same format. The environment variable needs to be set in the app.
Verification Steps
Note:
"when": {"$fhdate", "2018-10-15T15:49:09.746Z"},
. Click saveChecklist: