@loradb/lora-node 0.35.1 → 0.36.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -1
- package/docs/README.md +86 -0
- package/docs/concepts/graph-model.md +270 -0
- package/docs/concepts/nodes.md +285 -0
- package/docs/concepts/properties.md +348 -0
- package/docs/concepts/relationships.md +325 -0
- package/docs/concepts/result-formats.md +183 -0
- package/docs/concepts/schema-free.md +183 -0
- package/docs/cookbook.md +1081 -0
- package/docs/data-types/lists-and-maps.md +406 -0
- package/docs/data-types/overview.md +210 -0
- package/docs/data-types/scalars.md +376 -0
- package/docs/data-types/spatial.md +291 -0
- package/docs/data-types/temporal.md +349 -0
- package/docs/data-types/vectors.md +563 -0
- package/docs/errors.md +183 -0
- package/docs/functions/aggregation.md +372 -0
- package/docs/functions/list.md +522 -0
- package/docs/functions/map.md +207 -0
- package/docs/functions/math.md +421 -0
- package/docs/functions/number.md +197 -0
- package/docs/functions/overview.md +545 -0
- package/docs/functions/spatial.md +384 -0
- package/docs/functions/string.md +502 -0
- package/docs/functions/temporal.md +590 -0
- package/docs/functions/utility.md +137 -0
- package/docs/functions/vectors.md +772 -0
- package/docs/getting-started/installation.md +204 -0
- package/docs/getting-started/node.md +582 -0
- package/docs/getting-started/tutorial.md +334 -0
- package/docs/index.md +203 -0
- package/docs/limitations.md +291 -0
- package/docs/performance.md +219 -0
- package/docs/queries/aggregation.md +520 -0
- package/docs/queries/cheat-sheet.md +302 -0
- package/docs/queries/constraints.md +239 -0
- package/docs/queries/create.md +331 -0
- package/docs/queries/examples.md +453 -0
- package/docs/queries/index.md +169 -0
- package/docs/queries/indexes.md +538 -0
- package/docs/queries/match.md +429 -0
- package/docs/queries/ordering.md +359 -0
- package/docs/queries/parameters.md +328 -0
- package/docs/queries/paths.md +462 -0
- package/docs/queries/return-with.md +500 -0
- package/docs/queries/set-delete.md +369 -0
- package/docs/queries/unwind-merge.md +358 -0
- package/docs/queries/where.md +416 -0
- package/docs/snapshot.md +545 -0
- package/docs/troubleshooting.md +1158 -0
- package/docs/wal.md +570 -0
- package/docs/why.md +273 -0
- package/package.json +13 -14
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Lists and Maps"
|
|
3
|
+
description: "LoraDB's two composite value types — ordered nestable lists and string-keyed maps — including literals, indexing, slicing, nesting rules, and Cypher operations."
|
|
4
|
+
online: "https://loradb.com/docs/data-types/lists-and-maps"
|
|
5
|
+
package: "@loradb/lora-node@0.36.1"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Lists and Maps
|
|
9
|
+
|
|
10
|
+
Lists and maps are LoraDB's two composite types. Both nest, and both
|
|
11
|
+
hold any supported value — including other lists, maps, and
|
|
12
|
+
[typed values](./overview.md) such as temporal values and spatial points.
|
|
13
|
+
|
|
14
|
+
## Lists
|
|
15
|
+
|
|
16
|
+
Ordered, heterogeneous, nestable.
|
|
17
|
+
|
|
18
|
+
```cypher
|
|
19
|
+
RETURN [1, 2, 3];
|
|
20
|
+
RETURN ['a', 'b', 'c'];
|
|
21
|
+
RETURN [1, 'two', true, null]; // heterogeneous is fine
|
|
22
|
+
RETURN [[1, 2], [3, 4]] // nested
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Indexing
|
|
26
|
+
|
|
27
|
+
Zero-based; negatives count from the end; out-of-range → `null`.
|
|
28
|
+
|
|
29
|
+
```cypher
|
|
30
|
+
RETURN [10, 20, 30][0]; // 10
|
|
31
|
+
RETURN [10, 20, 30][-1]; // 30
|
|
32
|
+
RETURN [10, 20, 30][9] // null
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Slicing
|
|
36
|
+
|
|
37
|
+
End-exclusive. Open-ended slices work; negative bounds count from the end,
|
|
38
|
+
and a `null` bound makes the slice `null`.
|
|
39
|
+
|
|
40
|
+
```cypher
|
|
41
|
+
RETURN [1, 2, 3, 4, 5][1..3]; // [2, 3]
|
|
42
|
+
RETURN [1, 2, 3, 4, 5][..2]; // [1, 2]
|
|
43
|
+
RETURN [1, 2, 3, 4, 5][3..]; // [4, 5]
|
|
44
|
+
RETURN [1, 2, 3, 4, 5][-2..]; // [4, 5]
|
|
45
|
+
RETURN [1, 2, 3, 4, 5][..-1] // [1, 2, 3, 4]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Concatenation
|
|
49
|
+
|
|
50
|
+
```cypher
|
|
51
|
+
RETURN [1, 2] + [3, 4]; // [1, 2, 3, 4]
|
|
52
|
+
RETURN [1, 2] + 3; // [1, 2, 3]
|
|
53
|
+
RETURN 0 + [1, 2] // [0, 1, 2]
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Comprehensions
|
|
57
|
+
|
|
58
|
+
```cypher
|
|
59
|
+
// filter
|
|
60
|
+
RETURN [x IN [1, 2, 3, 4] WHERE x > 2] // [3, 4]
|
|
61
|
+
;// map
|
|
62
|
+
RETURN [x IN [1, 2, 3] | x * 10] // [10, 20, 30]
|
|
63
|
+
;// filter + map
|
|
64
|
+
RETURN [x IN [1, 2, 3, 4] WHERE x > 2 | x * 10] // [30, 40]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
See more in [List Functions → list comprehension](../functions/list.md#list-comprehension).
|
|
68
|
+
|
|
69
|
+
### Predicates (in [`WHERE`](../queries/where.md))
|
|
70
|
+
|
|
71
|
+
```cypher
|
|
72
|
+
MATCH (n) WHERE all(x IN n.scores WHERE x >= 0) RETURN n;
|
|
73
|
+
MATCH (n) WHERE any(x IN n.tags WHERE x = 'VIP') RETURN n;
|
|
74
|
+
MATCH (n) WHERE none(x IN n.scores WHERE x < 0) RETURN n;
|
|
75
|
+
MATCH (n) WHERE single(x IN n.roles WHERE x = 'owner') RETURN n
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### More list functions
|
|
79
|
+
|
|
80
|
+
See [List Functions](../functions/list.md) for the full list — includes
|
|
81
|
+
`value.size`, `list.first`, `list.rest`, `list.range`, `reduce`, comprehensions, and pattern
|
|
82
|
+
comprehensions.
|
|
83
|
+
|
|
84
|
+
### Parameters
|
|
85
|
+
|
|
86
|
+
```cypher
|
|
87
|
+
MATCH (u:User)
|
|
88
|
+
WHERE u.id IN $ids
|
|
89
|
+
RETURN u
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The `$ids` parameter must bind to a list. Lists in parameters may be
|
|
93
|
+
heterogeneous.
|
|
94
|
+
|
|
95
|
+
### Unwinding a list into rows
|
|
96
|
+
|
|
97
|
+
Combine with [`UNWIND`](../queries/unwind-merge.md#unwind) when you want
|
|
98
|
+
one row per element — the bulk-load idiom:
|
|
99
|
+
|
|
100
|
+
```cypher
|
|
101
|
+
UNWIND $items AS it
|
|
102
|
+
CREATE (:Item {sku: it.sku, price: it.price})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Lists from aggregation
|
|
106
|
+
|
|
107
|
+
[`collect`](../functions/aggregation.md#collect) turns rows into a list:
|
|
108
|
+
|
|
109
|
+
```cypher
|
|
110
|
+
MATCH (u:User)-[:OWNS]->(r:Repo)
|
|
111
|
+
RETURN u.name, collect(r.name) AS repos
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Maps
|
|
115
|
+
|
|
116
|
+
String-keyed dictionaries.
|
|
117
|
+
|
|
118
|
+
```cypher
|
|
119
|
+
RETURN {name: 'Ada', born: 1815};
|
|
120
|
+
RETURN {name: 'Ada', roles: ['admin', 'user'], profile: {tier: 'gold'}}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Key access
|
|
124
|
+
|
|
125
|
+
Dot access for static keys, bracket access for computed keys.
|
|
126
|
+
|
|
127
|
+
```cypher
|
|
128
|
+
WITH {name: 'Ada', born: 1815} AS m
|
|
129
|
+
RETURN m.name, m.born, m['name']
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Accessing a missing key returns `null`.
|
|
133
|
+
|
|
134
|
+
```cypher
|
|
135
|
+
WITH {a: 1} AS m
|
|
136
|
+
RETURN m.b // null
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Build a map from variables
|
|
140
|
+
|
|
141
|
+
```cypher
|
|
142
|
+
MATCH (u:User)
|
|
143
|
+
RETURN {id: u.id, name: u.name, active: u.active} AS user
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Dynamic lookup
|
|
147
|
+
|
|
148
|
+
Map literals use static keys. Use bracket lookup when the key comes
|
|
149
|
+
from a variable:
|
|
150
|
+
|
|
151
|
+
```cypher
|
|
152
|
+
WITH 'red' AS color, {red: 1, blue: 2} AS counts
|
|
153
|
+
RETURN counts[color] AS n
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Concatenation / merge
|
|
157
|
+
|
|
158
|
+
`+` merges two maps, right-hand keys win:
|
|
159
|
+
|
|
160
|
+
```cypher
|
|
161
|
+
RETURN {a: 1, b: 2} + {b: 20, c: 3}
|
|
162
|
+
// {a: 1, b: 20, c: 3}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Useful when combining with [`SET += $patch`](../queries/set-delete.md#merge-properties-):
|
|
166
|
+
|
|
167
|
+
```cypher
|
|
168
|
+
MATCH (u:User {id: $id})
|
|
169
|
+
SET u += $patch
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Maps on entities
|
|
173
|
+
|
|
174
|
+
Property maps on nodes / relationships are the same shape as literal
|
|
175
|
+
maps:
|
|
176
|
+
|
|
177
|
+
```cypher
|
|
178
|
+
CREATE (p:Person {name: 'Ada', born: 1815, skills: ['math', 'cs']});
|
|
179
|
+
MATCH (p:Person) RETURN p.name, p.skills
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Map projection
|
|
183
|
+
|
|
184
|
+
Project a subset of an entity's properties into a map — useful for
|
|
185
|
+
shaping results:
|
|
186
|
+
|
|
187
|
+
```cypher
|
|
188
|
+
MATCH (p:Person)
|
|
189
|
+
RETURN p {.name, .born}; // pick keys
|
|
190
|
+
RETURN p {.*}; // all properties
|
|
191
|
+
RETURN p {.name, yob: p.born}; // rename / computed
|
|
192
|
+
RETURN p {.name, friends: [(p)-[:KNOWS]->(f) | f.name]}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
A projection of `null` is `null`, whatever its keys: a node an
|
|
196
|
+
`OPTIONAL MATCH` did not find projects as `null`, not as a map of nulls.
|
|
197
|
+
|
|
198
|
+
The last form embeds a [pattern comprehension](../functions/list.md#pattern-comprehension)
|
|
199
|
+
inline.
|
|
200
|
+
|
|
201
|
+
### Map functions
|
|
202
|
+
|
|
203
|
+
Use [Map Functions](../functions/map.md) when a query needs to inspect or
|
|
204
|
+
reshape a map value.
|
|
205
|
+
|
|
206
|
+
```cypher
|
|
207
|
+
RETURN map.get({name: 'Ada'}, 'name'); // 'Ada'
|
|
208
|
+
RETURN map.has_key({name: 'Ada', email: null}, 'email'); // true
|
|
209
|
+
RETURN map.pick({id: 1, name: 'Ada', secret: 'x'}, ['id', 'name']);
|
|
210
|
+
RETURN map.rename({first_name: 'Ada'}, 'first_name', 'name')
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
These helpers return new maps. They do not mutate stored properties
|
|
214
|
+
unless you pass the result to a write clause such as `SET`.
|
|
215
|
+
|
|
216
|
+
### `keys` and `properties`
|
|
217
|
+
|
|
218
|
+
```cypher
|
|
219
|
+
MATCH (p:Person)
|
|
220
|
+
RETURN keys(p), properties(p)
|
|
221
|
+
// ['born', 'name'], {born: 1815, name: 'Ada'}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Parameters
|
|
225
|
+
|
|
226
|
+
Maps bind directly — useful as a bulk-update pattern:
|
|
227
|
+
|
|
228
|
+
```cypher
|
|
229
|
+
MATCH (u:User {id: $id})
|
|
230
|
+
SET u += $patch
|
|
231
|
+
RETURN u
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Where `$patch = {name: 'New Name', active: true}` from the host
|
|
235
|
+
language.
|
|
236
|
+
|
|
237
|
+
### UNWIND lists of maps
|
|
238
|
+
|
|
239
|
+
The idiomatic [bulk-load pattern](../queries/unwind-merge.md#unwind):
|
|
240
|
+
|
|
241
|
+
```cypher
|
|
242
|
+
UNWIND $rows AS row
|
|
243
|
+
CREATE (:Person {name: row.name, born: row.born})
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Serialisation
|
|
247
|
+
|
|
248
|
+
Across the HTTP boundary and in binding results:
|
|
249
|
+
|
|
250
|
+
| Value | Shape |
|
|
251
|
+
|---|---|
|
|
252
|
+
| `List` | JSON array |
|
|
253
|
+
| `Map` | JSON object |
|
|
254
|
+
|
|
255
|
+
Nested lists and maps round-trip cleanly. Typed values inside
|
|
256
|
+
(temporals, points, nodes) retain their `kind` discriminators.
|
|
257
|
+
|
|
258
|
+
## Common patterns
|
|
259
|
+
|
|
260
|
+
### Zip two lists
|
|
261
|
+
|
|
262
|
+
```cypher
|
|
263
|
+
WITH ['a', 'b', 'c'] AS keys, [1, 2, 3] AS vals
|
|
264
|
+
RETURN [i IN list.range(0, value.size(keys) - 1) | [keys[i], vals[i]]]
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Distinct list
|
|
268
|
+
|
|
269
|
+
No built-in `distinct(list)` helper — use `collect(DISTINCT x)` after
|
|
270
|
+
`UNWIND`:
|
|
271
|
+
|
|
272
|
+
```cypher
|
|
273
|
+
UNWIND [1, 2, 2, 3, 3, 3] AS x
|
|
274
|
+
RETURN collect(DISTINCT x) // [1, 2, 3]
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Top-N inside a collected list
|
|
278
|
+
|
|
279
|
+
```cypher
|
|
280
|
+
MATCH (u:User)-[:WROTE]->(p:Post)
|
|
281
|
+
WITH u, p ORDER BY p.published_at DESC
|
|
282
|
+
WITH u, collect(p.title)[..3] AS recent_three
|
|
283
|
+
RETURN u.name, recent_three
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Map of counts
|
|
287
|
+
|
|
288
|
+
```cypher
|
|
289
|
+
MATCH (u:User)-[:WROTE]->(p:Post)
|
|
290
|
+
WITH u.region AS region, count(*) AS posts
|
|
291
|
+
RETURN collect({region: region, posts: posts}) AS summary
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Nested projection
|
|
295
|
+
|
|
296
|
+
```cypher
|
|
297
|
+
MATCH (u:User)
|
|
298
|
+
RETURN u {
|
|
299
|
+
.id,
|
|
300
|
+
.name,
|
|
301
|
+
posts: [(u)-[:WROTE]->(p:Post) | p {.id, .title}]
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
One row per user; each row's `posts` is a list of small maps.
|
|
306
|
+
|
|
307
|
+
### List membership vs map key check
|
|
308
|
+
|
|
309
|
+
```cypher
|
|
310
|
+
// IN on a list
|
|
311
|
+
RETURN 2 IN [1, 2, 3] // true
|
|
312
|
+
|
|
313
|
+
;// 'in keys' on a map
|
|
314
|
+
WITH {a: 1, b: 2} AS m
|
|
315
|
+
RETURN 'a' IN keys(m) // true
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Append without duplicates
|
|
319
|
+
|
|
320
|
+
No `distinct_list` helper; compose with a list predicate:
|
|
321
|
+
|
|
322
|
+
```cypher
|
|
323
|
+
WITH [1, 2, 3] AS xs, 2 AS new_x
|
|
324
|
+
RETURN CASE WHEN new_x IN xs THEN xs ELSE xs + new_x END
|
|
325
|
+
// [1, 2, 3]
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Index of first match
|
|
329
|
+
|
|
330
|
+
```cypher
|
|
331
|
+
WITH ['a', 'b', 'c', 'd'] AS xs, 'c' AS needle
|
|
332
|
+
RETURN list.first([i IN list.range(0, value.size(xs) - 1) WHERE xs[i] = needle])
|
|
333
|
+
// 2
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
Uses a list comprehension to filter and [`list.first`](../functions/list.md#size--head--tail--last)
|
|
337
|
+
to pick the first.
|
|
338
|
+
|
|
339
|
+
### Merge nested maps
|
|
340
|
+
|
|
341
|
+
`+` on maps is shallow — to deep-merge, build the merged value
|
|
342
|
+
explicitly:
|
|
343
|
+
|
|
344
|
+
```cypher
|
|
345
|
+
WITH {a: 1, nested: {x: 1, y: 2}} AS base,
|
|
346
|
+
{nested: {y: 99, z: 3}, b: 2} AS patch
|
|
347
|
+
RETURN base + patch + {nested: base.nested + patch.nested}
|
|
348
|
+
// {a: 1, b: 2, nested: {x: 1, y: 99, z: 3}}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
## Edge cases
|
|
352
|
+
|
|
353
|
+
### Empty list / empty map
|
|
354
|
+
|
|
355
|
+
```cypher
|
|
356
|
+
RETURN value.size([]), value.size({}); // 0, 0
|
|
357
|
+
RETURN list.first([]) // null
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
`UNWIND []` emits zero rows. Watch for unbound parameters — an unset
|
|
361
|
+
`$rows` resolves to `null` and UNWIND of `null` also emits zero rows.
|
|
362
|
+
See [UNWIND → empty list](../queries/unwind-merge.md#empty-list).
|
|
363
|
+
|
|
364
|
+
### Heterogeneous lists
|
|
365
|
+
|
|
366
|
+
Nothing enforces uniform element types. Use
|
|
367
|
+
[`type.of`](../functions/overview.md#type-conversion-and-checking) in
|
|
368
|
+
`all(… WHERE …)` if you need a guarantee.
|
|
369
|
+
|
|
370
|
+
### Missing map keys
|
|
371
|
+
|
|
372
|
+
```cypher
|
|
373
|
+
WITH {a: 1} AS m
|
|
374
|
+
RETURN m.b; // null
|
|
375
|
+
RETURN m['b'] // null
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
No exception — missing keys silently return `null`. Be careful in
|
|
379
|
+
arithmetic: `m.b + 1` becomes `null`.
|
|
380
|
+
|
|
381
|
+
### Comparing maps
|
|
382
|
+
|
|
383
|
+
Equality checks compare all key/value pairs recursively. Ordering of
|
|
384
|
+
keys doesn't matter.
|
|
385
|
+
|
|
386
|
+
```cypher
|
|
387
|
+
RETURN {a: 1, b: 2} = {b: 2, a: 1} // true
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Limitations
|
|
391
|
+
|
|
392
|
+
- List element types are not constrained — there is no `List<Integer>`
|
|
393
|
+
constraint at creation time.
|
|
394
|
+
- Maps don't preserve any specific key ordering in responses — rely on
|
|
395
|
+
explicit projection (`RETURN m {.key}`) if order matters to your
|
|
396
|
+
consumer.
|
|
397
|
+
- No built-in `distinct(list)` helper — use `collect(DISTINCT x)`
|
|
398
|
+
after `UNWIND`.
|
|
399
|
+
|
|
400
|
+
## See also
|
|
401
|
+
|
|
402
|
+
- [**List Functions**](../functions/list.md) — every list helper.
|
|
403
|
+
- [**Aggregation → collect**](../functions/aggregation.md#collect).
|
|
404
|
+
- [**UNWIND**](../queries/unwind-merge.md#unwind) / [**MERGE**](../queries/unwind-merge.md#merge).
|
|
405
|
+
- [**RETURN → map projection**](../queries/return-with.md#map-projection).
|
|
406
|
+
- [**Properties**](../concepts/properties.md) — maps on entities.
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Supported Data Types in LoraDB"
|
|
3
|
+
description: "An index of every value type LoraDB supports — scalars, lists, maps, temporal types, spatial points, and vectors — with links to the per-type reference."
|
|
4
|
+
online: "https://loradb.com/docs/data-types/overview"
|
|
5
|
+
package: "@loradb/lora-node@0.36.1"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Supported Data Types in LoraDB
|
|
9
|
+
|
|
10
|
+
Every value in LoraDB — stored as a
|
|
11
|
+
[property](../concepts/properties.md), projected in a
|
|
12
|
+
[`RETURN`](../queries/return-with.md), or bound as a
|
|
13
|
+
[parameter](../queries/parameters.md) — has one of the types below.
|
|
14
|
+
|
|
15
|
+
## Category pages
|
|
16
|
+
|
|
17
|
+
| Category | Pages |
|
|
18
|
+
|---|---|
|
|
19
|
+
| **Scalars** (null, boolean, integer, float, string) | [Scalars](./scalars.md) |
|
|
20
|
+
| **Collections** (lists, maps) | [Lists & Maps](./lists-and-maps.md) |
|
|
21
|
+
| **Temporal** (date, time, datetime, duration) | [Temporal](./temporal.md) |
|
|
22
|
+
| **Spatial** (points) | [Spatial](./spatial.md) |
|
|
23
|
+
| **Vectors** (typed fixed-dimension coordinates) | [Vectors](./vectors.md) |
|
|
24
|
+
| **Graph** (node, relationship, path) | [below](#graph-types) |
|
|
25
|
+
|
|
26
|
+
## At-a-glance table
|
|
27
|
+
|
|
28
|
+
| Type | Example | `type.of` |
|
|
29
|
+
|---|---|---|
|
|
30
|
+
| `Null` | `null` | `"NULL"` |
|
|
31
|
+
| `Boolean` | `true`, `false` | `"BOOLEAN"` |
|
|
32
|
+
| `Integer` | `42`, `0xFF`, `0o17` | `"INTEGER"` |
|
|
33
|
+
| `Float` | `3.14`, `1.0e10` | `"FLOAT"` |
|
|
34
|
+
| `String` | `'hi'`, `"there"` | `"STRING"` |
|
|
35
|
+
| `List` | `[1, 2, 3]` | `"LIST<T>"` |
|
|
36
|
+
| `Map` | `{k: v}` | `"MAP"` |
|
|
37
|
+
| `Date`, `Time`, `DateTime`, `LocalTime`, `LocalDateTime` | `'2024-01-15'::DATE`, `'12:00:00'::TIME` | `"DATE"`, `"TIME"`, … |
|
|
38
|
+
| `Duration` | `'P30D'::DURATION` | `"DURATION"` |
|
|
39
|
+
| `Point` | `{x, y}::POINT` | `"POINT"` |
|
|
40
|
+
| `Vector` | `[1,2,3]::VECTOR<INTEGER>(3)` | `"VECTOR<INTEGER>(3)"` |
|
|
41
|
+
| `Node`, `Relationship`, `Path` | produced by queries | `"NODE"`, … |
|
|
42
|
+
|
|
43
|
+
## Where each type shows up
|
|
44
|
+
|
|
45
|
+
| Source | Lifetime |
|
|
46
|
+
|---|---|
|
|
47
|
+
| Node / relationship property | Persists in the graph until deleted |
|
|
48
|
+
| `RETURN` expression | One row, then gone |
|
|
49
|
+
| Parameter | Per-query call |
|
|
50
|
+
| `WITH` binding | Current pipeline stage |
|
|
51
|
+
| Function argument / result | Per expression |
|
|
52
|
+
|
|
53
|
+
Graph types (`Node`, `Relationship`, `Path`) are special: they appear
|
|
54
|
+
only in results, never as storable property values.
|
|
55
|
+
|
|
56
|
+
## Graph types
|
|
57
|
+
|
|
58
|
+
Produced by queries; not storable as properties.
|
|
59
|
+
|
|
60
|
+
| Type | Hydrated shape |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `Node` | `{kind: "node", id, labels, properties}` |
|
|
63
|
+
| `Relationship` | `{kind: "relationship", id, startId, endId, type, properties}` |
|
|
64
|
+
| `Path` | `{kind: "path", nodes, rels}` — alternating sequence |
|
|
65
|
+
|
|
66
|
+
```cypher
|
|
67
|
+
MATCH (a:Person)-[r:KNOWS]->(b:Person)
|
|
68
|
+
RETURN a, r, b // a, b are Nodes; r is a Relationship
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Narrow graph-typed results in host code with `isNode` /
|
|
72
|
+
`isRelationship` / `isPath` (JS —
|
|
73
|
+
[Node](../getting-started/node.md#type-guards)), `is_node` /
|
|
74
|
+
`is_relationship` / `is_path` (Python —
|
|
75
|
+
[guards](https://loradb.com/docs/getting-started/python#structured-result-handling)),
|
|
76
|
+
`IsNode` / `IsRelationship` / `IsPath` (Go —
|
|
77
|
+
[guards](https://loradb.com/docs/getting-started/go#structured-result-handling)), or
|
|
78
|
+
`LoraRuby.node?` / `relationship?` / `path?` (Ruby —
|
|
79
|
+
[guards](https://loradb.com/docs/getting-started/ruby#structured-result-handling)).
|
|
80
|
+
|
|
81
|
+
## Runtime type checking
|
|
82
|
+
|
|
83
|
+
Use [`type.of(x)`](../functions/overview.md#type-conversion-and-checking)
|
|
84
|
+
to discover a value's type at query time.
|
|
85
|
+
|
|
86
|
+
```cypher
|
|
87
|
+
RETURN type.of(1), // 'INTEGER'
|
|
88
|
+
type.of([1, 2, 3]), // 'LIST<INTEGER>'
|
|
89
|
+
type.of('2024-01-15'::DATE), // 'DATE'
|
|
90
|
+
type.of({x: 1, y: 2}::POINT), // 'POINT'
|
|
91
|
+
type.of([1,2,3]::VECTOR<INTEGER>(3)) // 'VECTOR<INTEGER>(3)'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`VECTOR` is the only built-in type whose `type.of` tag encodes
|
|
95
|
+
structural detail (coordinate type + dimension). Everything else
|
|
96
|
+
returns a plain tag like `INTEGER` or `LIST<INTEGER>`.
|
|
97
|
+
|
|
98
|
+
### Filter by runtime type
|
|
99
|
+
|
|
100
|
+
Useful on heterogeneous list properties:
|
|
101
|
+
|
|
102
|
+
```cypher
|
|
103
|
+
MATCH (n:Record)
|
|
104
|
+
WHERE all(x IN n.values WHERE type.of(x) = 'INTEGER')
|
|
105
|
+
RETURN n
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Distinguish graph types
|
|
109
|
+
|
|
110
|
+
```cypher
|
|
111
|
+
MATCH (n)
|
|
112
|
+
RETURN type.of(n) AS t, count(*) ORDER BY count(*) DESC
|
|
113
|
+
// typically all NODE, but useful for generic projections
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Conversion matrix
|
|
117
|
+
|
|
118
|
+
| From → To | `toInteger` | `toFloat` | `toString` | `toBoolean` |
|
|
119
|
+
|---|---|---|---|---|
|
|
120
|
+
| `Boolean` | `1` / `0` | `1.0` / `0.0` | `'true'` / `'false'` | — |
|
|
121
|
+
| `Integer` | — | `Float(n)` | decimal digits | `0 → false`, non-zero → `true` |
|
|
122
|
+
| `Float` | truncates | — | decimal string | — |
|
|
123
|
+
| `String` | parses / null | parses / null | — | `'true'` / `'false'` / null |
|
|
124
|
+
| `Null` | `null` | `null` | `null` | `null` |
|
|
125
|
+
|
|
126
|
+
See [`toString` / `toInteger` / `toFloat` / `toBoolean`](../functions/string.md#type-conversion)
|
|
127
|
+
for the full specification.
|
|
128
|
+
|
|
129
|
+
## Parameter binding
|
|
130
|
+
|
|
131
|
+
Host language values map to LoraDB types as follows — see your
|
|
132
|
+
binding's "Parameters" section for specifics:
|
|
133
|
+
|
|
134
|
+
| Host | LoraDB |
|
|
135
|
+
|---|---|
|
|
136
|
+
| `null` / `None` / `undefined` | `Null` |
|
|
137
|
+
| `bool` / `boolean` | `Boolean` |
|
|
138
|
+
| `int` / integer `number` / `i64` | `Integer` |
|
|
139
|
+
| `float` / non-integer `number` / `f64` | `Float` |
|
|
140
|
+
| `str` / `String` | `String` |
|
|
141
|
+
| `list` / `array` / `Vec` | `List` |
|
|
142
|
+
| `dict` / `object` / `BTreeMap` | `Map` |
|
|
143
|
+
| host helpers (`date()`, `wgs84()`, …) | `Date`, `Point`, etc. |
|
|
144
|
+
| `vector()` helper / tagged `{kind: "vector", …}` object | `Vector` |
|
|
145
|
+
|
|
146
|
+
Those helpers belong to the host binding APIs. In Cypher query text,
|
|
147
|
+
construct typed values with casts such as `'2026-05-01'::DATE`,
|
|
148
|
+
`{x: 1, y: 2}::POINT`, or `[1, 2, 3]::VECTOR<INTEGER>(3)`.
|
|
149
|
+
|
|
150
|
+
Details: [Rust](https://loradb.com/docs/getting-started/rust#parameterised-query),
|
|
151
|
+
[Node](../getting-started/node.md#parameterised-query),
|
|
152
|
+
[Python](https://loradb.com/docs/getting-started/python#parameterised-query),
|
|
153
|
+
[WASM](https://loradb.com/docs/getting-started/wasm#parameterised-query),
|
|
154
|
+
[Go](https://loradb.com/docs/getting-started/go#parameterised-query),
|
|
155
|
+
[Ruby](https://loradb.com/docs/getting-started/ruby#parameterised-query).
|
|
156
|
+
|
|
157
|
+
## Null across types
|
|
158
|
+
|
|
159
|
+
Every type has a single sentinel `Null` value — there's no
|
|
160
|
+
`Integer null` distinct from `String null`. Implications:
|
|
161
|
+
|
|
162
|
+
- `null = null` is **not** `true` — it's `null`. Use
|
|
163
|
+
[`IS NULL`](../queries/where.md#null-checks).
|
|
164
|
+
- `type.of(null)` is `'NULL'`, not `'NULL<INTEGER>'`.
|
|
165
|
+
- Missing map keys and missing properties return `null`, so
|
|
166
|
+
a null property and an absent property are indistinguishable. See
|
|
167
|
+
[Properties → Missing vs null](../concepts/properties.md#missing-vs-null).
|
|
168
|
+
- Arithmetic and most functions propagate `null` — use
|
|
169
|
+
[`coalesce`](../functions/overview.md#type-conversion-and-checking) or
|
|
170
|
+
[`CASE`](../queries/return-with.md#case-expressions) to supply defaults.
|
|
171
|
+
|
|
172
|
+
## Equality and ordering semantics
|
|
173
|
+
|
|
174
|
+
| Type | Equality | Ordering |
|
|
175
|
+
|---|---|---|
|
|
176
|
+
| Scalars (`Boolean`, `Integer`, `Float`, `String`) | Per-type | Per-type total order |
|
|
177
|
+
| `Null` | Propagates to `null` | Last ASC / first DESC |
|
|
178
|
+
| `List` | Element-wise, same length | Lex (element-by-element) |
|
|
179
|
+
| `Map` | Key/value set equal | — (not ordered) |
|
|
180
|
+
| `Point` | All components + SRID | — (not ordered) |
|
|
181
|
+
| Temporals | Same type, same instant | Per-type chronological |
|
|
182
|
+
| `Vector` | Coord type + dimension + every value — differs across coord types even with equal values | Deterministic but unspecified — order by a scalar score instead |
|
|
183
|
+
| `Node` / `Relationship` | By internal `id()` | — |
|
|
184
|
+
| `Path` | Structural equality | — |
|
|
185
|
+
|
|
186
|
+
Anything left unordered has equality only — attempting
|
|
187
|
+
[`ORDER BY`](../queries/ordering.md) on a map/point/node column doesn't
|
|
188
|
+
raise, but the sort is effectively a no-op.
|
|
189
|
+
|
|
190
|
+
## What isn't a type
|
|
191
|
+
|
|
192
|
+
- **Binary / byte arrays** — supported as byte-string properties through
|
|
193
|
+
binding wire formats; there is no Cypher byte literal.
|
|
194
|
+
- **Fixed-precision decimals** — not supported; use scaled integers
|
|
195
|
+
or strings.
|
|
196
|
+
- **User-defined types** — not supported.
|
|
197
|
+
- **Enums** — not a native type; use a string or integer by
|
|
198
|
+
convention.
|
|
199
|
+
|
|
200
|
+
See [Limitations](../limitations.md#data-types) for the full list.
|
|
201
|
+
|
|
202
|
+
## See also
|
|
203
|
+
|
|
204
|
+
- [**Scalars**](./scalars.md), [**Lists & Maps**](./lists-and-maps.md),
|
|
205
|
+
[**Temporal**](./temporal.md), [**Spatial**](./spatial.md) — per-type reference.
|
|
206
|
+
- [**Functions → Overview**](../functions/overview.md) — casts, `coalesce`, `type.of`.
|
|
207
|
+
- [**Properties**](../concepts/properties.md) — how types attach to entities.
|
|
208
|
+
- [**Queries → Parameters**](../queries/parameters.md) — binding typed values from the host.
|
|
209
|
+
- [**Result formats**](../concepts/result-formats.md) — how these types
|
|
210
|
+
come back over the wire.
|