Skip to content

basalt / subscriptions/src / CouponStore

Interface: CouponStore ​

Defined in: subscriptions/src/coupon.ts:115

Methods ​

all() ​

> all(): Promise<CouponRecord[]>

Defined in: subscriptions/src/coupon.ts:118

Returns ​

Promise<CouponRecord[]>


get() ​

> get(code): Promise<CouponRecord | null>

Defined in: subscriptions/src/coupon.ts:117

Parameters ​

code ​

string

Returns ​

Promise<CouponRecord | null>


incrementRedemptions() ​

> incrementRedemptions(code, limit?): Promise<number | null>

Defined in: subscriptions/src/coupon.ts:127

Atomically increment the redemption counter; returns the new count. When limit is given, increment ONLY while the count is below it and return null when the cap is already reached — a single conditional write, so two concurrent redemptions of the last slot cannot both succeed. (A store that ignores limit still works: redeem() rejects a count above the cap, but the counter is then left one over.)

Parameters ​

code ​

string

limit? ​

number

Returns ​

Promise<number | null>


save() ​

> save(coupon): Promise<void>

Defined in: subscriptions/src/coupon.ts:116

Parameters ​

coupon ​

CouponRecord

Returns ​

Promise<void>

Released under the MIT License.