| 1053 | } |
| 1054 | |
| 1055 | func (c *connection) InsertUsergroup(ctx context.Context, opts *database.InsertUsergroupOptions) (*database.Usergroup, error) { |
| 1056 | if err := database.Validate(opts); err != nil { |
| 1057 | return nil, err |
| 1058 | } |
| 1059 | |
| 1060 | res := &database.Usergroup{} |
| 1061 | err := c.getDB(ctx).QueryRowxContext(ctx, ` |
| 1062 | INSERT INTO usergroups (org_id, name, managed) VALUES ($1, $2, $3) RETURNING * |
| 1063 | `, opts.OrgID, opts.Name, opts.Managed).StructScan(res) |
| 1064 | if err != nil { |
| 1065 | return nil, parseErr("usergroup", err) |
| 1066 | } |
| 1067 | return res, nil |
| 1068 | } |
| 1069 | |
| 1070 | func (c *connection) UpdateUsergroupName(ctx context.Context, name, groupID string) (*database.Usergroup, error) { |
| 1071 | res := &database.Usergroup{} |