Skip to content

Commit 971e4e1

Browse files
committed
Update Readme and indents
1 parent cafeca2 commit 971e4e1

File tree

4 files changed

+63
-53
lines changed

4 files changed

+63
-53
lines changed

README.adoc

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,36 @@ image::{model-image}[]
9292

9393
=== Code Examples
9494

95-
.Javascript
96-
[source,javascript,subs=attributes]
95+
.link:code/javascript/example.js[JavaScript]
96+
[source,javascript]
9797
----
9898
include::code/javascript/example.js[]
9999
----
100100

101-
.Java
102-
[source,java,subs=attributes]
101+
.link:code/java/Example.java[Java]
102+
[source,java]
103103
----
104104
include::code/java/Example.java[]
105105
----
106106

107-
.Python
108-
[source,python,subs=attributes]
107+
.link:code/python/example.py[Python]
108+
[source,python]
109109
----
110110
include::code/python/example.py[]
111111
----
112112

113-
.C#
114-
[source,csharp,subs=attributes]
113+
.link:code/csharp/Example.cs[C#]
114+
[source,csharp]
115115
----
116116
include::code/csharp/Example.cs[]
117117
----
118118

119+
.link:code/go/example.go[Go]
120+
[source,go]
121+
----
122+
include::code/go/example.go[]
123+
----
124+
119125
=== Feedback
120126

121127
Repository: {repo}

code/csharp/Example.cs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,29 @@
99
using System.Text;
1010
using System.Threading.Tasks;
1111
using Neo4j.Driver;
12-
12+
1313
namespace dotnet {
14-
class Example {
15-
static async Task Main() {
16-
var driver = GraphDatabase.Driver("neo4j+s://demo.neo4jlabs.com:7687",
17-
AuthTokens.Basic("mUser", "s3cr3t"));
14+
class Example {
15+
static async Task Main() {
16+
var driver = GraphDatabase.Driver("neo4j+s://demo.neo4jlabs.com:7687",
17+
AuthTokens.Basic("mUser", "s3cr3t"));
1818

19-
var cypherQuery =
20-
@"
21-
MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
22-
";
19+
var cypherQuery =
20+
@"
21+
MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName
22+
";
2323

24-
var session = driver.AsyncSession(o => o.WithDatabase("movies"));
25-
var result = await session.ReadTransactionAsync(async tx =>
26-
{
27-
var r = await tx.RunAsync(cypherQuery,
28-
new { movieTitle="The Matrix"});
29-
return await r.ToListAsync();
30-
});
31-
await session?.CloseAsync();
32-
foreach (var row in result)
33-
Console.WriteLine(row["actorName"].As<string>());
34-
}
35-
}
24+
var session = driver.AsyncSession(o => o.WithDatabase("movies"));
25+
var result = await session.ReadTransactionAsync(async tx => {
26+
var r = await tx.RunAsync(cypherQuery,
27+
new { movieTitle="The Matrix"});
28+
return await r.ToListAsync();
29+
});
30+
31+
await session?.CloseAsync();
32+
foreach (var row in result)
33+
Console.WriteLine(row["actorName"].As<string>());
34+
35+
}
36+
}
3637
}

code/java/Example.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@
99

1010
public class Example {
1111

12-
public static void main(String...args) {
13-
Driver driver = GraphDatabase.driver("neo4j+s://demo.neo4jlabs.com:7687",
14-
AuthTokens.basic("mUser","s3cr3t"));
15-
try (Session session = driver.session(SessionConfig.forDatabase("movies"))) {
16-
17-
String cypherQuery =
18-
"MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName";
19-
20-
var result = session.readTransaction(
21-
tx -> tx.run(cypherQuery,
22-
parameters("movieTitle","The Matrix"))
23-
.list());
24-
25-
for (Record record : result) {
26-
System.out.println(record.get("actorName").asString());
27-
}
28-
}
29-
driver.close();
12+
public static void main(String...args) {
13+
14+
Driver driver = GraphDatabase.driver("neo4j+s://demo.neo4jlabs.com:7687",
15+
AuthTokens.basic("mUser","s3cr3t"));
16+
17+
try (Session session = driver.session(SessionConfig.forDatabase("movies"))) {
18+
19+
String cypherQuery =
20+
"MATCH (m:Movie {title:$movieTitle})<-[:ACTED_IN]-(a:Person) RETURN a.name as actorName";
21+
22+
var result = session.readTransaction(
23+
tx -> tx.run(cypherQuery,
24+
parameters("movieTitle","The Matrix"))
25+
.list());
26+
27+
for (Record record : result) {
28+
System.out.println(record.get("actorName").asString());
29+
}
3030
}
31+
driver.close();
32+
}
3133
}
3234

3335

code/render-code.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ RESULTCOLUMN=`grep :result-column: $TARGET/README.adoc | cut -d' ' -f2-`
1414

1515
# "Cloud Atlas"
1616
echo For example \"$NAME\" running
17-
echo $QUERY
17+
echo "$QUERY"
18+
echo
1819
echo Expecting \"$EXPECT\" with {\"$PARAMNAME\": \"$PARAMVALUE\"} returning \"$RESULTCOLUMN\"
1920

20-
echo "$QUERY"
21-
echo "----"
22-
echo ${PARAMNAME} ${PARAMVALUE} ${RESULTCOLUMN}
21+
#echo "$QUERY"
22+
#echo "----"
23+
#echo ${PARAMNAME} ${PARAMVALUE} ${RESULTCOLUMN}
2324

2425
echo "Adding language examples to $TARGET, Hit ctrl-c to abort"
2526
read
@@ -43,13 +44,13 @@ for file in */?xample.*; do
4344
mkdir -p $TARGET/code/$LANG
4445
cp $file $TARGET/code/$file
4546
indent=`grep 'MATCH (m:Movie' $TARGET/code/$file | cut -d'M' -f1 | cut -d'"' -f1`
46-
echo "Indent #$indent#"
47+
# echo "Indent #$indent#"
4748
if [ $LANG == "java" ]; then
4849
Q2=`/bin/echo -n "$QUERY" | sed -e "s/\(.*\)/$indent\"\1\" +/g" | tr '\n' '§' | sed -e 's/\+$/;/g'`
4950
else
5051
Q2=`/bin/echo -n "$QUERY" | sed -e "s/\(.*\)/$indent\1/g" | tr '\n' '§'`
5152
fi
52-
echo "$Q2"
53+
# echo "$Q2"
5354
sed -i -e "s/^.*MATCH (m:Movie.*$/$Q2/g" $TARGET/code/$file
5455
mv $TARGET/code/$file $TARGET/code/$file.tmp
5556
tr '§' '\n' < $TARGET/code/$file.tmp > $TARGET/code/$file

0 commit comments

Comments
 (0)