class Cart < ApplicationRecord
belongs_to :user, optional: true
has_many :cart_items, dependent: :destroy
scope :for_session, ->(token) { where(session_token: token) }
scope :active, -> { where(merged_at: nil) }
const { pool } = require('./db');
async function recordEvent(client, { eventId, type, payload }) {
const { rows } = await client.query(
`INSERT INTO webhook_events (event_id, type, payload, status)
VALUES ($1, $2, $3, 'received')
import jakarta.persistence.*;
import java.math.BigDecimal;
import java.util.Objects;
@Entity
@Table(name = "accounts")
module EventBus
@subscribers = Hash.new { |h, k| h[k] = [] }
class << self
def subscribe(event_class, handler = nil, &block)
callable = handler || block