-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhelp.js
78 lines (45 loc) · 3.06 KB
/
help.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module.exports = `
Author: Einar Otto Stangvik (twitter.com/einaros)
License: ISC
Examples:
Adding entities, properties and connections:
============================================
Add entity 'Dog' with id='Fido', set age=10:
$ neopipe 'Dog:Fido (age:10)'
Add entity 'Dog' with id='Fido Boy', set age='very old', add connection 'OWNED_BY' to Man with id='Roy':
$ neopipe 'Dog:"Fido Boy" (age:"very old") OWNED_BY Man:Roy'
Add property 'Likes dog'='yes' to existing entity Man with id='Roy':
$ neopipe 'Man:Roy ("Likes dog":yes)'
Process lines from standard input:
============================================
Add Thing with id='foo' connected via 'is_not_a' to Thing with id 'baz':
$ echo foo bar baz | neopipe 'Thing:{1} is_not_a Thing:{3}'
Add the same things as above, and pass all stdin along to the next piped command:
$ echo foo bar baz | neopipe -o pipe 'Thing:{1} is_not_a Thing:{3}' | something_else.sh
Find files in a folder hierarchy, add FILE entities with the filenames as id,
set a property 'size' on the FILE with the result of a shell executed command (stat) with
the filename interpolated ({1}), add a connection to a HASH with id set to the result of
another command (md5):
$ find node_modules -type f | neopipe 'FILE:"{1}" (size:"{!stat -f %z {1}}") HAS HASH:{!md5 -q {1}}'
Simulate adding an entity 'a' with id='az', which is the result of splitting the third entry
three times with different delimiters. Show verbose output (repeat 'v' multiple times for more verbose):
$ echo 'foo bar "b-az,bax"' | neopipe -vt 'a:"{3/,:1/\\-:2}"'
As above, but make the entity id a sha1 hash of the interpolated value:
$ echo 'foo bar "b-az,bax"' | neopipe -vt 'a:"{#3/,:1/\\-:2}"'
As above, but make the entity id a sha1 hash of the uppercase'd interpolated value:
$ echo 'foo bar "b-az,bax"' | neopipe -vt 'a:"{##3/,:1/\\-:2}"'
Add an entity 'a', but try to interpolate id from a missing field, so fall back to a default value 'ugh':
$ echo 'foo bar "b-az,bax"' | neopipe 'a:"{4?ugh}"'
Add an entity 'a', but try to interpolate id from a missing field, fall back to the result of 'uptime':
$ echo 'foo bar "b-az,bax"' | neopipe 'a:"{4?{!uptime}}"'
In a contrived example, stream insertion of new entities every two seconds, and write each result from
Neo4j as JSON to standard output:
$ while true; do date; sleep 2; done | neopipe --stream -o json 'Uuid:{!uuid} generated_at Time:"{1-}"'
Executing raw Cypher queries:
============================================
Detach and delete all entities:
$ neopipe -e 'MATCH (n) DETACH DELETE (n)'
Use the JSON output mode, no input expression and an end query to extract existing entity relationships
(based on advanced example in README) and parse the output with jq (https://stedolan.github.io/jq/):
$ neopipe -o json -e 'MATCH p=()-[r:LOOKS_LIKE]->() RETURN p' | jq .
`;