MakeQuery takes a goven query and performs it against the user database.
(q string)
| 51 | |
| 52 | // MakeQuery takes a goven query and performs it against the user database. |
| 53 | func (u *UserDAO) MakeQuery(q string) ([]User, error) { |
| 54 | var users []User |
| 55 | ctx := context.Background() |
| 56 | query := u.db.WithContext(ctx) |
| 57 | queryResp, err := u.queryAdaptor.Parse(q) |
| 58 | if err != nil { |
| 59 | return nil, err |
| 60 | } |
| 61 | query = query.Model(User{}).Where(queryResp.Raw, sql_adaptor.StringSliceToInterfaceSlice(queryResp.Values)...) |
| 62 | err = query.Find(&users).Error |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | return users, nil |
| 67 | } |