You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I see that $places.city; is similar to $places.map(|$item| $item.city);
[
'frankfurt',
'berlin'
]
Example 2
CREATE place:westbahnhof SET city = 'frankfurt';
CREATE place:sudbahnhof SET city = 'frankfurt';
CREATE place:ostbahnhof SET city = 'frankfurt';
CREATE place:berlinwall SET city = 'berlin';
LET $frankfurtPlaces = (SELECT VALUE id FROM place WHERE city = 'frankfurt');
CREATE town:frankfurt SET places = $frankfurtPlaces;
I see that SELECT *, places.city FROM town; is similar to SELECT *, places.map(|| {city: places.map(|$item| $item.city)}) FROM town;.
If we replace with places.{city}, both examples work consistently. Nice!
However, the syntax places.city carries different meanings in the two examples above.
It could be $places.map(|$item| $item.city); in this case, or places.map(|| {city: places.map(|$item| $item.city)}) in another case.
I’m not here to criticize; Surreal DB is an impressive product.
However, I want to highlight that inconsistency in language design can lead to confusion, which is best avoided.
Moving forward, Surreal DB should strive for greater consistency in its syntax.
A strong example of well-designed language syntax is Kotlin.
In Kotlin, every syntax element maintains a consistent meaning,
ensuring that developers are never caught off guard when encountering familiar expressions.
Surreal DB could benefit from adopting this principle in its future design decisions.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please see the examples below:
Example 1
I see that
$places.city;
is similar to$places.map(|$item| $item.city);
Example 2
I see that
SELECT *, places.city FROM town;
is similar toSELECT *, places.map(|| {city: places.map(|$item| $item.city)}) FROM town;
.Problem
If we replace with
places.{city}
, both examples work consistently. Nice!However, the syntax
places.city
carries different meanings in the two examples above.It could be
$places.map(|$item| $item.city);
in this case, orplaces.map(|| {city: places.map(|$item| $item.city)})
in another case.I’m not here to criticize; Surreal DB is an impressive product.
However, I want to highlight that inconsistency in language design can lead to confusion, which is best avoided.
Moving forward, Surreal DB should strive for greater consistency in its syntax.
A strong example of well-designed language syntax is Kotlin.
In Kotlin, every syntax element maintains a consistent meaning,
ensuring that developers are never caught off guard when encountering familiar expressions.
Surreal DB could benefit from adopting this principle in its future design decisions.
Beta Was this translation helpful? Give feedback.
All reactions