DELETE item from table pg-promise

I am creating an api to remove items from a table using pg-promise, and here is my code:

router.delete('/:entityName/:id', function(req, res){
    var query = req.query;
    if(Object.keys(query).length){
    var sql = 'DELETE FROM ' + req.params.entityName + ' WHERE id '
    + req.params.id + ' AND '  ;

    for(var key in query) {
        sql += ' ' + key + ' = ' + '\'' + query[key] + '\'';
    }

    db.any(sql)
    .then(function(data){
        res.send(data);
    })
    .catch(function (error) {
    console.log('ERROR:', error)
    });
  }
})

This is how it should be done in order to delete item by id or by key. My output should be like: DELETE /products/5?name=iPhone or DELETE /products/5?price=300