c语言sscanf函数的用法是什么
314
2022-08-25
dgraph 创建节点和边的时候判断节点是否存在,如果存在,就不创建,如果不存在,则创建
neo4j里面有一个merge的操作,能够自动帮助我们来判断节点和边在数据库里面属否存在,dgraph有没有呢,答案是有的,就是upsert,我的示例代码:
upsert { query { var(func: eq(person_id, "xxx")) { Person as uid } var(func: eq(company_id, "yyy")) { Company as uid } } mutation { set { uid(Person)
来看看官网怎么解释的:
To use upsert operations on a predicate, specify the @upsert directive in the schema. When committing transactions involving predicates with the @upsert directive, Dgraph checks index keys for conflicts, helping to enforce uniqueness constraints when running concurrent upserts.
我的schema为:
是不是很简单呢。
怎么验证呢,多moute几次,然后用下面的语句查一下,看有没有重复:
{ data(func: eq(person_id, "xxx")) { name person_id manager @facets(orderasc:position) { name company_id } }}
参考文献
[1]. IDs and Upsert Block. https://dgraph.io/docs/mutations/#external-ids-and-upsert-block
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~