const User = use("App/Models/User");
// this is not working.. and no any example of filtering data by dates.. please help
const records = User.query().where("created_at", "<", Moment().substract(1, "day"));
// i am trying to fetch all users who were registered atleast 24 hours/ 1 day ago or before .. not today.
but it gives parse error
You need to format the moment date object as a mysql friendly string:
const yesterday = Moment().substract(1, 'day').format('YYYY-MM-DD HH:mm:ss')
const records = User.query().where('created_at', '<', yesterday)
Closing since @webdevian answered the question.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
You need to format the moment date object as a mysql friendly string: