generate sql from js