### ─── STRESS INSERT & FETCH ──────────────────────────────────────────────────
### Companion HTTP file for the stress test dataset.
###
### WORKFLOW:
###   1. Start the MoltenDB server.
###   2. Run §0 (Login) and copy the token into @token below.
###   3. Run §1 (Generate data) from the terminal:
###        cargo run --example generate_stress_data
###   4. Run §2 (Bulk insert) from the terminal:
###        cargo run --example stress_insert
###   5. Use §3–§8 below to manually inspect and query the inserted data.
###


### ─── §0. Login ───────────────────────────────────────────────────────────────
POST https://localhost:1538/login
Content-Type: application/json

{
  "username": "admin",
  "password": "admin123"
}

### Paste the token from the response here:
@token = eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTc3NTY3MDE3MH0.O84hmhEIPWKmUv6MhTsXriI3HxRik4M9s2JERSe4EWE

### ─── §1. Fetch entire stress_items collection (all 100 000 docs) ─────────────
### WARNING: this returns a large payload — use §2 for a lighter check.
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress"
}

### ─── §2. Fetch first document — stress_0 ──────────────────────────────────────
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "keys": "stress_000000"
}

### ─── §3. Fetch a mid-range document — stress_49999 ───────────────────────────
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "keys": "stress_049999"
}

### ─── §4. Fetch the last document — stress_99999 ──────────────────────────────
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "keys": "stress_099999"
}

### ─── §5. Query — all Apple laptops ─────────────────────────────────────────
### Expected: every 10th item (brand cycles over 10 brands, Apple is index 1)
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "fields": ["brand", "model", "price"],
  "where": { "brand": { "$eq": "Apple" } }
}

### ─── §6. Query — in-stock items under $1000 ────────────────────────────────
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "fields": ["brand", "model", "price", "in_stock"],
  "where": {
    "in_stock": true,
    "price": { "$lt": 1000 }
  }
}

### ─── §7. Query — gaming items (tag contains "gaming") ─────────────────────
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "fields": ["brand", "model", "tags"],
  "where": { "tags": { "$ct": "gaming" } }
}

### ─── §8. Query — OLED displays, sorted by price descending ─────────────────
POST https://localhost:1538/get
Content-Type: application/json
Authorization: Bearer {{token}}

{
  "collection": "stress",
  "fields": ["brand", "model", "price", "display"],
  "where": { "display.panel": { "$eq": "OLED" } },
  "sort": { "field": "price", "order": "desc" }
}
