func fetchRelatedCards(ctx context.Context, db allDocer, cardID string) ([]*fb.Card, error) {
	startKey, endKey := relatedKeyRange(cardID)
	rows, err := db.AllDocs(context.TODO(), map[string]interface{}{
		"include_docs": true,
		"start_key":    startKey,
		"end_key":      endKey,
	})
	if err != nil {
		return nil, err
	}
	cards := make([]*fb.Card, 0)
	for rows.Next() {
		if cardID == rows.ID() {
			// Skip the reference card
			continue
		}
		var card fb.Card
		if err := rows.ScanDoc(&card); err != nil {
			return nil, errors.Wrap(err, "scan doc")
		}
		cards = append(cards, &card)
	}
	if err := rows.Err(); err != nil && err != io.EOF {
		return nil, err
	}
	return cards, nil
}
// fetchRelatedCards fetches cards related to the provided card ID.
fetchRelatedCards fetches cards related to the provided card ID.
// fetchRelatedCards fetches cards related to the provided card ID .
func fetchRelatedCards(ctx context.Context, db allDocer, cardID string) ([]*fb.Card, error) {
	startKey, endKey := relatedKeyRange(cardID)
	rows, err := db.AllDocs(context.TODO(), map[string]interface{}{
		"include_docs": true,
		"start_key":    startKey,
		"end_key":      endKey,
	})
	if err != nil {
		return nil, err
	}
	cards := make([]*fb.Card, 0)
	for rows.Next() {
		if cardID == rows.ID() {
			continue
		}
		var card fb.Card
		if err := rows.ScanDoc(&card); err != nil {
			return nil, errors.Wrap(err, "scan doc")
		}
		cards = append(cards, &card)
	}
	if err := rows.Err(); err != nil && err != io.EOF {
		return nil, err
	}
	return cards, nil
}
func fetchRelatedCards ( ctx context . Context , db allDocer , cardID string ) ( [ ] * fb . Card , error ) { startKey , endKey := relatedKeyRange ( cardID ) rows , err := db . AllDocs ( context . TODO ( ) , map [ string ] interface { } { " " : true , " " : startKey , " " : endKey , } ) if err != nil { return nil , err } cards := make ( [ ] * fb . Card , 0 ) for rows . Next ( ) { if cardID == rows . ID ( ) { continue } var card fb . Card if err := rows . ScanDoc ( & card ) ; err != nil { return nil , errors . Wrap ( err , " " ) } cards = append ( cards , & card ) } if err := rows . Err ( ) ; err != nil && err != io . EOF { return nil , err } return cards , nil }
fetchRelatedCards fetches cards related to the provided card ID.
fetchRelatedCards fetches cards related to the provided card ID .
// Skip the reference card