func()

in sobject/collections/query.go [44:65]


func (q *query) payload(sobject string, records []sobject.Querier) (*bytes.Reader, error) {
	fields := make(map[string]interface{})
	ids := make(map[string]interface{})
	for _, querier := range records {
		if sobject != querier.SObject() {
			return nil, fmt.Errorf("sobject collections: sobjects do not match got %s want %s", querier.SObject(), sobject)
		}
		ids[querier.ID()] = nil
		for _, field := range querier.Fields() {
			fields[field] = nil
		}
	}
	queryPayload := collectionQueryPayload{
		IDs:    q.keyArray(ids),
		Fields: q.keyArray(fields),
	}
	payload, err := json.Marshal(queryPayload)
	if err != nil {
		return nil, err
	}
	return bytes.NewReader(payload), nil
}