{
  "kind": "documentation",
  "format": 1,
  "note": "Reference text, not instructions. One verified relate sample from https://relatedb.ai/docs/reference/api/swift/: the program exactly as the page shows it, the standard output a run of it recorded (npm run docs:samples compares every replay with it byte for byte), the relate client build, toolchain and platform of the last replay, and how the docs' sample runner builds and runs it. Before launch every client is a source build, not a published package; verified.client names the upstream commit it was built from, and verified.docs_engine the build the rest of the docs were recorded from.",
  "id": "values",
  "url": "https://relatedb.ai/docs/reference/api/swift/samples/values.json",
  "page": {
    "id": "reference/api/swift",
    "title": "Swift API",
    "url": "https://relatedb.ai/docs/reference/api/swift/",
    "md_url": "https://relatedb.ai/docs/reference/api/swift.md"
  },
  "section": {
    "anchor": "example",
    "heading": "Example",
    "url": "https://relatedb.ai/docs/reference/api/swift/#example"
  },
  "language": "swift",
  "client": "Swift",
  "file": "main.swift",
  "env": null,
  "code": "import Relate\n\nlet conn = try Database.inMemory().connect()\nlet result = try conn.query(\"\"\"\n    CREATE (ada:Person {name: 'Ada'})-[k:KNOWS {since: 2024}]->(grace:Person {name: 'Grace'})\n    RETURN ada, k, 9007199254740993 AS big, 1.5 AS ratio, date('2024-05-06') AS day,\n           datetime('2024-05-06T09:30:00[Europe/Berlin]') AS meeting, duration('P1Y2M') AS term,\n           point({x: 1, y: 2}) AS spot, vector([1, 2, 3], 3, INT8) AS counts\n    \"\"\")\nfor (column, value) in zip(result.columns, result.rows[0]) {\n    print(\"\\(column): \\(value.kind) \\(value)\")\n}",
  "code_sha256": "cff634a6e18beb6ea6a9a1f472febb72d38ea70bb22e2e8822ef4d0fcb86d68c",
  "source_sha256": "53b0257800ec2ca06ca142ce0a1a49bdaa9f6b0c56fabc100d21edc750681bdf",
  "output": {
    "text": "ada: node (4:relate-neo4j:n0:Person {name: 'Ada'})\nk: relationship (4:relate-neo4j:n0)-[5:relate-neo4j:r0:KNOWS {since: 2024}]->(4:relate-neo4j:n1)\nbig: int 9007199254740993\nratio: float 1.5\nday: date 2024-05-06\nmeeting: dateTime 2024-05-06T09:30:00+02:00[Europe/Berlin]\nterm: duration duration(months: 14, days: 0, seconds: 0, nanoseconds: 0)\nspot: point point({srid: 7203, x: 1.0, y: 2.0})\ncounts: vector vector<INTEGER8>[1, 2, 3]",
    "sha256": "097cb031daa883bbe71b1dbd31aee521cf64a7453be0c67e745209ad92930902"
  },
  "verified": {
    "version": "0.1.2",
    "client": {
      "label": "Swift",
      "package": "Relate",
      "engine_commit": "f0c09d2",
      "client_commit": "f0c09d2",
      "build": "A copy of Package.swift and clients/swift at upstream v0.1.2 (f0c09d2), with an XCFramework made from librelate_ffi built from the same commit.",
      "toolchain": {
        "swift": "6.4.2"
      }
    },
    "packages": [],
    "replayed": "2026-11-09",
    "platform": "macOS on arm64",
    "docs_engine": {
      "version": "0.1.2",
      "commit": "f0c09d2",
      "source_build": false
    }
  },
  "run": {
    "runner": "npm run docs:samples",
    "setup": "bash scripts/samples/setup.sh --upstream <path to the relate checkout>",
    "variables": [
      "RELATE_SWIFT",
      "RELATE_SWIFT_PACKAGE"
    ],
    "program": "<build dir>/Sources/sample/main.swift",
    "files": [
      {
        "path": "<build dir>/Package.swift",
        "content": "// swift-tools-version: 6.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"sample\",\n    platforms: [.macOS(.v13)],\n    dependencies: [.package(path: \"$RELATE_SWIFT_PACKAGE\")],\n    targets: [\n        .executableTarget(\n            name: \"sample\",\n            dependencies: [.product(name: \"Relate\", package: \"relate\")],\n            path: \"Sources/sample\"\n        ),\n    ],\n    swiftLanguageModes: [.v6]\n)\n"
      },
      {
        "path": "<build dir>/sample-bin",
        "from": "<directory of $RELATE_SWIFT_PACKAGE>/scratch/debug/sample",
        "note": "the built product, copied out after the build"
      }
    ],
    "build": {
      "command": [
        "$RELATE_SWIFT",
        "build",
        "-c",
        "debug",
        "--package-path",
        "<build dir>",
        "--scratch-path",
        "<directory of $RELATE_SWIFT_PACKAGE>/scratch",
        "--product",
        "sample",
        "--quiet"
      ],
      "environment": {
        "DO_NOT_TRACK": "1",
        "RELATE_LOCAL_XCFRAMEWORK": "1"
      },
      "directory": "<build dir>",
      "timeout_s": 600
    },
    "run": {
      "command": [
        "<build dir>/sample-bin"
      ],
      "environment": {
        "DO_NOT_TRACK": "1"
      },
      "directory": "<run dir>",
      "timeout_s": 60
    },
    "passes": "It exits 0 within 60 s and prints at least one line on standard output.",
    "output": "Standard output, with line endings as \\n, trailing spaces and blank lines removed, and the temporary directories' paths written as `.`; standard error is not recorded.",
    "placeholders": {
      "<run dir>": "a fresh, empty temporary directory: the program's working directory, deleted afterwards",
      "<build dir>": "a second fresh temporary directory, where a compiled sample is built",
      "$NAME": "a variable from the env.sh that scripts/samples/setup.sh writes (described in its header)"
    }
  }
}
