| 160 | } |
| 161 | |
| 162 | func (s *PgStmt) queryExec(args []driver.Value) (js.Value, error) { |
| 163 | m := map[string]interface{}{ |
| 164 | "rowMode": "array", |
| 165 | "types": getPGTypeParser(), |
| 166 | "name": s.key, |
| 167 | "text": s.query, |
| 168 | } |
| 169 | |
| 170 | vals := make([]interface{}, len(args)) |
| 171 | for i, a := range args { |
| 172 | switch v := a.(type) { |
| 173 | case []byte: |
| 174 | vals[i] = js.ValueOf(string(v)) |
| 175 | default: |
| 176 | vals[i] = js.ValueOf(v) |
| 177 | } |
| 178 | } |
| 179 | m["values"] = vals |
| 180 | |
| 181 | res, rej := await(s.client.Call("query", m)) |
| 182 | |
| 183 | if len(rej) != 0 { |
| 184 | err := errors.New(rej[0].Get("message").String()) |
| 185 | return js.Null(), err |
| 186 | } |
| 187 | |
| 188 | return res[0], nil |
| 189 | } |