py2neo-如何为我的节点使用merge_one函数以及多个属性? [英] py2neo - How can I use merge_one function along with multiple attributes for my node?

查看:1106
本文介绍了py2neo-如何为我的节点使用merge_one函数以及多个属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经克服了通过使用merge_one函数避免在数据库上创建重复节点的问题,

I have overcome the problem of avoiding the creation of duplicate nodes on my DB with the use of merge_one functions which works like that:

t=graph.merge_one("User","ID","someID") 

这将创建具有唯一ID的节点.我的问题是我找不到将多个属性/属性以及自动添加的ID(例如日期)添加到我的节点的方法. 我已经设法以旧的重复"方式实现了这一点,但是由于merge_one无法接受更多参数,因此现在不起作用了!有什么想法吗?

which creates the node with unique ID. My problem is that I can't find a way to add multiple attributes/properties to my node along with the ID which is added automatically (date for example). I have managed to achieve this the old "duplicate" way but it doesn't work now since merge_one can't accept more arguments! Any ideas???

推荐答案

Graph.merge_one仅允许您指定一个键值对,因为它与节点标签和属性上的唯一性约束一起使用.通过merge_one通过其唯一ID查找节点,然后设置属性,有什么问题吗?

Graph.merge_one only allows you to specify one key-value pair because it's meant to be used with a uniqueness constraint on a node label and property. Is there anything wrong with finding the node by its unique id with merge_one and then setting the properties?

t = graph.merge_one("User", "ID", "someID")
t['name'] = 'Nicole'
t['age'] = 23
t.push()

这篇关于py2neo-如何为我的节点使用merge_one函数以及多个属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆