neo4j_bolt 0.1.16 → 0.1.17
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.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/bin/neo4j_bolt +3 -2
- data/lib/neo4j_bolt/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e5736941097cb8c26e81e68e7792447cc402e7ee982a69e39ee30c38f732e6
|
4
|
+
data.tar.gz: 37fd2134e0ea856282d70469f787272f4fa6fa34df1f89d39487b3088a54b542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86b3f5cec2a7e121aacc892d936ce35a4783fadbd463acd44c34fd20da897c45c2451c54c90f95df4c58db9a671234860700dc21819eda913f3b06cfaf3f9645
|
7
|
+
data.tar.gz: 87ecb696d47e8bc37837787f006c9226cf674e31b5823b671bae6508c113b99f3e9923724e13a7684998db11900745f997c0185c1b62d86806c16a0c9ec39f1e
|
data/README.md
CHANGED
@@ -96,6 +96,19 @@ node = neo4j_query_expect_one("MATCH (n) RETURN n LIMIT 1;")['n']
|
|
96
96
|
|
97
97
|
If there's zero, two, or more results, this will raise a `ExpectedOneResultError`.
|
98
98
|
|
99
|
+
## Using transactions
|
100
|
+
|
101
|
+
Any Neo4j query will run in its own transaction by default. If you want to group multiple queries into a transaction to make sure they either succeed completely or fail completely, use `transaction` like this:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
transaction do
|
105
|
+
neo4j_query("CREATE (n:Node {a: 1});")
|
106
|
+
neo4j_query("CREATE (n:Node {b: 1});")
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
Transactions can be nested, with the inner transactions doing nothing and the outermost transaction being committed unless something goes wrong in which case the outermost transaction gets rolled back. No matter how often you nest transactions, there's only one transaction from the perspective of Neo4j.
|
111
|
+
|
99
112
|
## Setting up constraints and indexes
|
100
113
|
|
101
114
|
Use `setup_constraints_and_indexes` like this:
|
@@ -169,7 +182,7 @@ You can see nodes and relationships with their current numbers, plus all propert
|
|
169
182
|
|
170
183
|
Uniqueness constraints and indexes (if available) are shown as well if they are defined on a single node or relationship with a single attribute.
|
171
184
|
|
172
|
-
If a property is an integer and
|
185
|
+
If a property is an integer and has `ts` or `timestamp` in its name separated from other alphanumeric characters (like `ts_created` but not like `hits`), it gets treated as a UNIX timestamp (just for the visualization).
|
173
186
|
|
174
187
|
## Development
|
175
188
|
|
data/bin/neo4j_bolt
CHANGED
@@ -284,14 +284,15 @@ class App
|
|
284
284
|
mean_s = sprintf('%1.1f', props[lbl][key][:sum][c].to_f / props[lbl][key][:counts][c]).chomp('.0')
|
285
285
|
min_s = (c == 'float') ? sprintf('%1.1f', props[lbl][key][:min][c]) : props[lbl][key][:min][c]
|
286
286
|
max_s = (c == 'float') ? sprintf('%1.1f', props[lbl][key][:max][c]) : props[lbl][key][:max][c]
|
287
|
-
|
287
|
+
c_is_ts = (c == 'int') && (key.split(/[^a-zA-Z]+/).any? { |x| x == 'ts' || x == 'timestamp'} )
|
288
|
+
if c_is_ts
|
288
289
|
min_s = Time.at(props[lbl][key][:min][c]).strftime('%Y-%m-%d')
|
289
290
|
max_s = Time.at(props[lbl][key][:max][c]).strftime('%Y-%m-%d')
|
290
291
|
end
|
291
292
|
if props[lbl][key][:min][c] == props[lbl][key][:max][c]
|
292
293
|
label += "<td border='1' color='#{rel ? '#888888' : '#000000'}' valign='top' align='center' colspan='6'>#{min_s}</td>"
|
293
294
|
else
|
294
|
-
if
|
295
|
+
if c_is_ts
|
295
296
|
label += "<td border='1' color='#{rel ? '#888888' : '#000000'}' valign='top' align='right' colspan='3'>#{min_s}</td>"
|
296
297
|
label += "<td border='1' color='#{rel ? '#888888' : '#000000'}' valign='top' align='right' colspan='3'>#{max_s}</td>"
|
297
298
|
else
|
data/lib/neo4j_bolt/version.rb
CHANGED