class

MiniStore::Store

Inherits Reference < Object

Basit, bellek içi veri deposu. Gerçek bir projede burası veri tabanı katmanı olurdu; uç noktaların davranışı değişmeden değiştirilebilir.

Constants

INSTANCE = Store.new

Constructors

Instance methods

add_to_cart(user_id : String, product : Product, quantity : Int32) : Array(CartItem)

Aynı ürün ikinci kez eklenirse adet üzerine eklenir.

Source
cart_for(user_id : String) : Array(CartItem)
Source
clear_cart(user_id : String) : Nil
Source
create_order(user_id : String) : Order | String

Sipariş oluşturma: stok kontrolü, stok düşme ve sepet boşaltma tek bir kilit altında yapılır; adımlardan biri başarısız olursa hiçbir değişiklik uygulanmaz.

Source
find_product(id : Int32) : Product | Nil
Source
find_user(id : String) : User | Nil
Source
list_products(category : String | Nil = nil, min_price : Int32 | Nil = nil, max_price : Int32 | Nil = nil, sort : String = "id", direction : String = "asc", page : Int32 = 1, per_page : Int32 = 10)
Source
orders_of(user_id : String) : Array(Order)
Source
upsert_user(user : User) : User
Source