4 ms·
I would guess something like: class Collection<T implements Entity> { void insert(T entity) { String vals = entity.props.map(escapeSql)
by rmrfrmrf 9y ago
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);
}
}
- weberc2 9y agoGo supports that today. Slice is a generic collection. Map will need to become for loops, but that's minor.