

Welcome to the Tour of SurrealDB!1: Connecting to a database2: Creating records3: Using the ONLY keyword4: Non-ASCII record IDs5: Parentheses and accessing fields6: Deleting records7: Field order in objects8: Tips when selecting records9: Casting and aliases10: Affixes11: Updating records12: Linking records13: Viewing the database as a whole14: Schemafull and schemaless15: Viewing the schema16: Literal types and assertions17: INSERT and using JSON18: FOR loops19: Basic graph relations20: Creating graph edges21: Querying graph relations22: Graph relations at greater depth23: Adding and improving data24: Defining events25: Defining indexes26: Improving the schema27: Visualising graph paths28: Recursive queries: setup29: Recursive queries30: More on recursive queries31: AI vector searchDone the tour!
3: Using the ONLY keyword
SurrealDB returns an array of results by default. But in queries that return a single record, you can add ONLY to return just the record itself instead of an array of records.
This is useful when working with the output of a query. Instead of needing to use [0] to pull out the first item at index 0, the output of the query itself is now just a single record.
It is also helpful when using one of the SDKs and you want a response that can be deserialised easily into a single object.