             r.delete() if r?.get?()
           , 15000
 
-          r = n1.to(n2, form.type, {description: form.description}).get()
+          r = n1.to(n2, form.type, {description: form.description, updatedAt}).get()
         else
           r = oldRel.setProperties({description: form.description, updatedAt}).get()
 


      n1 = db.nodes form.from
      n2 = db.nodes form.to
      n1.setProperty {updatedAt}
      n2.setProperty {updatedAt}

      r = n1.to(n2, form.type, {description: form.description}).get()
      r.from    = r.start
      r.to      = r.end
      r.label   = r.type

  db = new Neo4jDB 'http://localhost:7474', {username: 'neo4j', password: '1234'}

  unless db.queryOne 'MATCH (n) RETURN n LIMIT 1'
    db.querySync 'WITH ["Andres","Wes","Rik","Mark","Peter","Kenny","Michael","Stefan","Max","Chris"] AS names FOREACH (r IN range(0,19) | CREATE (:Person {removed: false, updatedAt: timestamp(), name:names[r % size(names)]+" "+r}));'


  Meteor.methods
    graph: (timestamp = 0) -> 
      check timestamp, Number
      nodes = {}
      edges = {}

      visGraph = 
        nodes : []
        edges: []
      graph = db.query('MATCH (n) WHERE n.updatedAt >= {timestamp} RETURN DISTINCT n UNION ALL MATCH ()-[n]-() WHERE n.updatedAt >= {timestamp} RETURN DISTINCT n', {timestamp}).fetch()

      if graph.length is 0
        updatedAt = timestamp
      else
        updatedAt = +new Date

        for row in graph
          if row?.n and not nodes?[row.n.id]
            if row.n?.start
              edge = 
                id: row.n.id
                from: row.n.start
                to: row.n.end
                type: row.n.type
                label: row.n.type
                arrows: 'to'
                group: row.n.type
              edges[row.n.id] = _.extend edge, row.n
            else
              node = 
                id: row.n.id
                labels: row.n.labels
                label: row.n.name
                group: row.n.labels[0]
              nodes[row.n.id] = _.extend node, row.n

        visGraph.edges = (value for key, value of edges)
        visGraph.nodes = (value for key, value of nodes)

      return {updatedAt, data: visGraph}

    createNode: (form) ->
      check form, Object
      updatedAt = +new Date
      n = db.nodes({description: form.description, name: form.name, updatedAt}).replaceLabels([form.label]).get()
      n.label = n.name
      n.group = n.labels[0]
      n
