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
Copy file name to clipboardExpand all lines: README.md
+17-11Lines changed: 17 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -421,8 +421,10 @@ rxSession
421
421
422
422
### Numbers and the Integer type
423
423
424
-
The Neo4j type system includes 64-bit integer values.
425
-
However, JavaScript can only safely represent integers between `-(2`<sup>`53`</sup>`- 1)` and `(2`<sup>`53`</sup>`- 1)`.
424
+
The Neo4j type system uses 64-bit signed integer values. The range of values is between `-(2`<sup>`64`</sup>`- 1)` and `(2`<sup>`63`</sup>`- 1)`.
425
+
426
+
However, JavaScript can only safely represent integers between `Number.MIN_SAFE_INTEGER``-(2`<sup>`53`</sup>`- 1)` and `Number.MAX_SAFE_INTEGER``(2`<sup>`53`</sup>`- 1)`.
427
+
426
428
In order to support the full Neo4j type system, the driver will not automatically convert to javascript integers.
427
429
Any time the driver receives an integer value from Neo4j, it will be represented with an internal integer type by the driver.
428
430
@@ -431,6 +433,7 @@ _**Any javascript number value passed as a parameter will be recognized as `Floa
431
433
#### Writing integers
432
434
433
435
Numbers written directly e.g. `session.run("CREATE (n:Node {age: $age})", {age: 22})` will be of type `Float` in Neo4j.
436
+
434
437
To write the `age` as an integer the `neo4j.int` method should be used:
435
438
436
439
```javascript
@@ -439,7 +442,7 @@ var neo4j = require('neo4j-driver')
To write integers larger than can be represented as JavaScript numbers, use a string argument to `neo4j.int`:
445
+
To write an integer value that are not within the range of `Number.MIN_SAFE_INTEGER``-(2`<sup>`53`</sup>`- 1)` and `Number.MAX_SAFE_INTEGER``(2`<sup>`53`</sup>`- 1)`, use a string argument to `neo4j.int`:
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if you know that they will not exceed `(2`<sup>`53`</sup>`- 1)` in size.
455
+
In Neo4j, the type Integer can be larger what can be represented safely as an integer with JavaScript Number.
456
+
457
+
It is only safe to convert to a JavaScript Number if you know that the number will be in the range `Number.MIN_SAFE_INTEGER``-(2`<sup>`53`</sup>`- 1)` and `Number.MAX_SAFE_INTEGER``(2`<sup>`53`</sup>`- 1)`.
458
+
453
459
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber`, and `neo4j.integer.toString`.
454
460
455
461
```javascript
456
-
varaSmallInteger=neo4j.int(123)
457
-
if (neo4j.integer.inSafeRange(aSmallInteger)) {
458
-
var aNumber =aSmallInteger.toNumber()
462
+
varsmallInteger=neo4j.int(123)
463
+
if (neo4j.integer.inSafeRange(smallInteger)) {
464
+
var aNumber =smallInteger.toNumber()
459
465
}
460
466
```
461
467
462
-
If you will be handling integers larger than that, you should convert them to strings:
468
+
If you will be handling integers that is not within the JavaScript safe range of integers, you should convert the value to a string:
0 commit comments