I think you can set from to be 0 if there is no query.from.

That way it is safe to do ( createdAt < +from ) later, and no longer need the if ( from )