Trouble with Programmatically Updating Media URLS in API to Cloudfront domain URL

The problem is db.query is low level api