Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I would guess something like:

    class Collection<T implements Entity> {
        void insert(T entity) {
            String vals = entity.props.map(escapeSql).join(",");
            String qs = entity.props.map(x => "?").join(",");
            PreparedStatement p = db.prepare("insert into %s (%s) values (%s);", this.tableName, qs, vals);
            db.submit(p);
        }
    }


Go supports that today. Slice is a generic collection. Map will need to become for loops, but that's minor.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: