var client = new Neo4jClient("http://neo4j:7474")
# Create a node
var andres = new NeoNode
andres["name"] = "Andres"
client.save_node(andres)
assert andres.is_linked
Once linked, nodes cannot be created twice:
var oldurl = andres.url
client.save_node(andres) # do nothing
assert andres.url == oldurl
# Save the node in base
#
# var client = new Neo4jClient("http://neo4j:7474")
#
# # Create a node
# var andres = new NeoNode
# andres["name"] = "Andres"
# client.save_node(andres)
# assert andres.is_linked
#
# Once linked, nodes cannot be created twice:
#
# var oldurl = andres.url
# client.save_node(andres) # do nothing
# assert andres.url == oldurl
fun save_node(node: NeoNode): Bool do
if node.is_linked then return true
node.neo = self
var batch = new NeoBatch(self)
batch.save_node(node)
# batch.create_edges(node.out_edges)
var errors = batch.execute
if not errors.is_empty then
errors.add_all errors
return false
end
local_nodes[node.url.to_s] = node
return true
end
lib/neo4j/neo4j.nit:105,2--133,4