2

I am trying to recreate Nicole White's microblog application powered by Flask and Neo4j tutorial but using py2neo v3 rather than v2. I'm a novice but keen to understand & learn by tinkering...

I know that graph.merge_one() has been replaced by graph.merge() in v3 but I cannot figure out how to get tags out of my database, or if they don't exist then create them in order to use them to create a relationship with a node.

Nicole does it like this using py2neo v2...

for tag in tags:
        t=graph.merge_one("Tag", "name", tag)
        rel=Relationship(t, "TAGGED", post)
        graph.create(rel)

How can I do it using graph.merge() from py2neo v3?

davidism
  • 121,510
  • 29
  • 395
  • 339
user1613312
  • 374
  • 2
  • 15

1 Answers1

4

This appears to work but...

for tag in tags:
        t = Node("Tag", name=tag)
        graph.merge(t)
        rel=Relationship(t, "TAGGED", post)
        graph.create(rel)

I wish there was a tutorial to follow. The docs are so terse...

user1613312
  • 374
  • 2
  • 15
  • 2
    I really just wanted to upvote your comment about the poor documentation and wanting examples/tutorials to follow. It's really hard to get anything done as it is. – Aaron Bramson Nov 21 '18 at 06:31
  • I'll share info if I discover anything. @technige or anyone - how about it? – user1613312 Nov 22 '18 at 08:31