Fix model index coffeescript template

Fix Incorrect check to ignore index from import
Fix invalid coffeescript syntax
Add missing db variable definition