FIX db query in js