mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-26 04:07:50 +00:00
1 line
6.1 KiB
JSON
1 line
6.1 KiB
JSON
{"primaryContentSections":[{"kind":"declarations","declarations":[{"tokens":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"forKey"},{"kind":"text","text":"("},{"kind":"externalParam","text":"_"},{"kind":"text","text":" "},{"kind":"internalParam","text":"key"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"String","preciseIdentifier":"s:SS"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SQLSelection","preciseIdentifier":"s:4GRDB12SQLSelectionV","text":"SQLSelection"}],"languages":["swift"],"platforms":["macOS"]}]},{"kind":"content","content":[{"anchor":"discussion","level":2,"type":"heading","text":"Discussion"},{"type":"paragraph","inlineContent":[{"type":"text","text":"For example:"}]},{"type":"codeListing","syntax":"swift","code":["\/\/ SELECT (score + bonus) AS totalScore FROM player","let totalScore = (Column(\"score\") * Column(\"bonus\")).forKey(\"totalScore\")","let request = Player.select(totalScore)"]},{"type":"paragraph","inlineContent":[{"type":"text","text":"If you need to refer to the aliased column in another part of a request,"},{"type":"text","text":" "},{"type":"text","text":"use "},{"type":"reference","isActive":true,"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ColumnExpression\/detached"},{"type":"text","text":". For example:"}]},{"type":"codeListing","syntax":"swift","code":["\/\/ SELECT (score + bonus) AS totalScore","\/\/ FROM player","\/\/ ORDER BY totalScore","let request = Player"," .select(totalScore)"," .order(Column(\"totalScore\").detached)"]}]}],"schemaVersion":{"major":0,"minor":3,"patch":0},"sections":[],"variants":[{"paths":["\/documentation\/grdb\/sqlrequest\/forkey(_:)"],"traits":[{"interfaceLanguage":"swift"}]}],"identifier":{"url":"doc:\/\/GRDB\/documentation\/GRDB\/SQLRequest\/forKey(_:)","interfaceLanguage":"swift"},"abstract":[{"type":"text","text":"Returns an aliased result column."}],"kind":"symbol","metadata":{"role":"symbol","title":"forKey(_:)","roleHeading":"Instance Method","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"forKey"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"String","preciseIdentifier":"s:SS"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"SQLSelection","preciseIdentifier":"s:4GRDB12SQLSelectionV"}],"symbolKind":"method","externalID":"s:4GRDB22SQLSpecificExpressiblePAAE6forKeyyAA12SQLSelectionVSSF::SYNTHESIZED::s:4GRDB10SQLRequestV","extendedModule":"GRDB","modules":[{"name":"GRDB"}]},"hierarchy":{"paths":[["doc:\/\/GRDB\/documentation\/GRDB","doc:\/\/GRDB\/documentation\/GRDB\/SQLSupport","doc:\/\/GRDB\/documentation\/GRDB\/SQLRequest","doc:\/\/GRDB\/documentation\/GRDB\/SQLRequest\/SQLSpecificExpressible-Implementations"]]},"references":{"doc://GRDB/documentation/GRDB/SQLRequest":{"role":"symbol","title":"SQLRequest","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"SQLRequest"}],"abstract":[{"type":"text","text":"An SQL request that can decode database rows."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SQLRequest","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"SQLRequest"}],"url":"\/documentation\/grdb\/sqlrequest"},"doc://GRDB/documentation/GRDB/SQLSelection":{"role":"symbol","title":"SQLSelection","fragments":[{"kind":"keyword","text":"struct"},{"kind":"text","text":" "},{"kind":"identifier","text":"SQLSelection"}],"abstract":[{"type":"text","text":"An SQL result column."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SQLSelection","kind":"symbol","type":"topic","navigatorTitle":[{"kind":"identifier","text":"SQLSelection"}],"url":"\/documentation\/grdb\/sqlselection"},"doc://GRDB/documentation/GRDB":{"role":"collection","title":"GRDB","abstract":[{"type":"text","text":"A toolkit for SQLite databases, with a focus on application development"}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB","kind":"symbol","type":"topic","url":"\/documentation\/grdb"},"doc://GRDB/documentation/GRDB/ColumnExpression/detached":{"role":"symbol","title":"detached","fragments":[{"kind":"keyword","text":"var"},{"kind":"text","text":" "},{"kind":"identifier","text":"detached"},{"kind":"text","text":": "},{"kind":"typeIdentifier","text":"SQLExpression","preciseIdentifier":"s:4GRDB13SQLExpressionV"}],"abstract":[{"type":"text","text":"An SQL expression that refers to an aliased column"},{"type":"text","text":" "},{"type":"text","text":"("},{"type":"codeVoice","code":"expression AS alias"},{"type":"text","text":")."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/ColumnExpression\/detached","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/columnexpression\/detached"},"doc://GRDB/documentation/GRDB/SQLRequest/SQLSpecificExpressible-Implementations":{"role":"collectionGroup","title":"SQLSpecificExpressible Implementations","abstract":[],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SQLRequest\/SQLSpecificExpressible-Implementations","kind":"article","type":"topic","url":"\/documentation\/grdb\/sqlrequest\/sqlspecificexpressible-implementations"},"doc://GRDB/documentation/GRDB/SQLSupport":{"role":"collectionGroup","title":"SQL, Prepared Statements, Rows, and Values","abstract":[{"type":"text","text":"SQL is the fundamental language for accessing SQLite databases."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SQLSupport","kind":"article","type":"topic","url":"\/documentation\/grdb\/sqlsupport"},"doc://GRDB/documentation/GRDB/SQLRequest/forKey(_:)":{"role":"symbol","title":"forKey(_:)","fragments":[{"kind":"keyword","text":"func"},{"kind":"text","text":" "},{"kind":"identifier","text":"forKey"},{"kind":"text","text":"("},{"kind":"typeIdentifier","text":"String","preciseIdentifier":"s:SS"},{"kind":"text","text":") -> "},{"kind":"typeIdentifier","text":"SQLSelection","preciseIdentifier":"s:4GRDB12SQLSelectionV"}],"abstract":[{"type":"text","text":"Returns an aliased result column."}],"identifier":"doc:\/\/GRDB\/documentation\/GRDB\/SQLRequest\/forKey(_:)","kind":"symbol","type":"topic","url":"\/documentation\/grdb\/sqlrequest\/forkey(_:)"}}} |