MCPcopy
hub / github.com/dgraph-io/dgraph / queryGroup

Function queryGroup

acl/acl.go:558–584  ·  view source on GitHub ↗
(ctx context.Context, txn *dgo.Txn, groupid string,
	fields ...string)

Source from the content-addressed store, hash-verified

556}
557
558func queryGroup(ctx context.Context, txn *dgo.Txn, groupid string,
559 fields ...string) (group *Group, err error) {
560
561 // write query header
562 query := fmt.Sprintf(`
563 query search($groupid: string){
564 group(func: eq(dgraph.xid, $groupid)) @filter(type(dgraph.type.Group)) {
565 uid
566 %s
567 }
568 }`, strings.Join(fields, ", "))
569
570 queryVars := map[string]string{
571 "$groupid": groupid,
572 }
573
574 queryResp, err := txn.QueryWithVars(ctx, query, queryVars)
575 if err != nil {
576 fmt.Printf("Error while querying group with id %s: %v\n", groupid, err)
577 return nil, err
578 }
579 group, err = UnmarshalGroup(queryResp.GetJson(), "group")
580 if err != nil {
581 return nil, err
582 }
583 return group, nil
584}
585
586func queryAndPrintUser(ctx context.Context, txn *dgo.Txn, userId string) error {
587 user, err := queryUser(ctx, txn, userId)

Callers 4

groupAddFunction · 0.85
delFunction · 0.85
getUserModNQuadFunction · 0.85
queryAndPrintGroupFunction · 0.85

Calls 1

UnmarshalGroupFunction · 0.85

Tested by

no test coverage detected