INNER CODE UNIT · Go

func

arp242/goatcounter · api_token.go:216

func (t *APITokens) List(ctx context.Context) error {
	err := zdb.Select(ctx, t,
		`select * from api_tokens where site_id=$1 and user_id=$2`,
		MustGetSite(ctx).IDOrParent(), GetUser(ctx).ID)
	return errors.Wrap(err, "APITokens.List")
}

// Find API tokens: by ID if ident is a number, or by token if it's not.
func (t *APITokens) Find(ctx context.Context, ident []string) error {
	ids, strs := splitIntStr(ident)
	err := zdb.Select(ctx, t, `select * from api_tokens where
		{{:ids api_token_id in (:ids) or}}
		{{:strs! 0=1}}
		{{:strs token in (:strs)}}`,
		map[string]any{"ids": ids, "strs": strs})
	return errors.Wrap(err, "APITokens.Find")
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…