| 401 | } |
| 402 | |
| 403 | func (feq *FsEventQuery) loadUser(ctx context.Context, query *UserQuery, nodes []*FsEvent, init func(*FsEvent), assign func(*FsEvent, *User)) error { |
| 404 | ids := make([]int, 0, len(nodes)) |
| 405 | nodeids := make(map[int][]*FsEvent) |
| 406 | for i := range nodes { |
| 407 | fk := nodes[i].UserFsevent |
| 408 | if _, ok := nodeids[fk]; !ok { |
| 409 | ids = append(ids, fk) |
| 410 | } |
| 411 | nodeids[fk] = append(nodeids[fk], nodes[i]) |
| 412 | } |
| 413 | if len(ids) == 0 { |
| 414 | return nil |
| 415 | } |
| 416 | query.Where(user.IDIn(ids...)) |
| 417 | neighbors, err := query.All(ctx) |
| 418 | if err != nil { |
| 419 | return err |
| 420 | } |
| 421 | for _, n := range neighbors { |
| 422 | nodes, ok := nodeids[n.ID] |
| 423 | if !ok { |
| 424 | return fmt.Errorf(`unexpected foreign-key "user_fsevent" returned %v`, n.ID) |
| 425 | } |
| 426 | for i := range nodes { |
| 427 | assign(nodes[i], n) |
| 428 | } |
| 429 | } |
| 430 | return nil |
| 431 | } |
| 432 | |
| 433 | func (feq *FsEventQuery) sqlCount(ctx context.Context) (int, error) { |
| 434 | _spec := feq.querySpec() |