zubairehman/Flogs

deleteAllLogsByFilter not doing anything

chrislaurie-io opened this issue · 3 comments

With the code below I expect all logs to be deleted - that is all logs will have a timestamp less than this moment. But it doesn't delete anything. If I look at the data I see the all entries still there with an earlier timestamp.

FLog.deleteAllLogsByFilter( filters: [ Filter.lessThan(DBConstants.FIELD_TIMESTAMP, DateTime.now()), ], );

clearLogs() works as expected.

It works for DBConstants.FIELD_TIME_IN_MILLIS but not for FIELD_TIMESTAMP

I found out why. Timestamp in FLog is stored as a string. The only way to get less or greater than to work is to have a string that represents a date that can be sorted chronologically on the string value itself. This implies a format of yyyy/mm/dd kk:hh:mm. If you configure f_log to use that format and then in your app format the filter date to the same format, it works.

I'm not sure if sembast can't handle a datetime data type or, if they do, why f_log choose to implement it as a string.

@zubairehman issue can be closed