
7: Field order in objects
Now that all the place records that we used for testing are deleted, let's create the one library that we will use in this tour. This time it will have three fields besides an id: a name, an address, and the number of floors. To do this, we can use SET along with the names of these fields and a value for each.
While the fields inside the CREATE statement weren't in alphabetical order, the output always will be.
[
{
address: '2025 Statement Street, Riverdale',
floors: 8,
id: library:76wabj5zw4g4qcuy9o3y,
name: 'Surreal Library',
place_type: 'library'
}
]This behaviour is because anything can be compared and ordered in SurrealDB. Even objects can be compared, because their fields are lined up alphabetically and compared in that order.
This next example returns true because the value 9 for floors (alphabetically the first field) in the first object is greater than 8 in the second.
But if you change name to a_name it will now be compared before floors. And because "A Library" (which starts with A) is less than "Surreal Library" (which starts with S), the output is now false.
THE PLATFORM
Everything an application and its agents know. Five surfaces, one engine.
Database
Document, graph, vector, time-series and relational in one engine.

Agent Memory
What an agent learns, with its source and its time, in the same engine.

Cloud
Managed clusters in the regions you choose, scaled on demand.

Studio
Query, explore and design the schema from the browser.

MCP
Every model that speaks MCP reaches the database and the memory directly.

IN PRODUCTION
Trusted at scale. Samsung, Nvidia, Verizon, Tencent, and Walmart run on SurrealDB.
14,000+
Developers building on SurrealDB Cloud
4M+
Developers building on SurrealDB worldwide
FROM THE TEAMS
SurrealDB gives us a foundation where we can unify semantic search, knowledge graphs, and AI-driven decision making without stitching together multiple systems. Collapsing responsibility into SurrealDB has become our default engineering posture.
VP of Engineering, Later