本文介绍了将地图添加为节点或关系中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将地图添加为属性?我想将地址行1、2等存储在address属性本身内.

Is there a way to add a map as property? I want to store address line 1, 2 etc inside the address property itself.

类似的东西-

RETURN {address: {firstline:"a", secondline:"b"}, name:"ABC"}

但是,当我在CREATE或SET中尝试此操作时,会给我错误.

However when I try this in CREATE or SET it gives me error.

我尝试过-

create (a:Person {name: "ABC", address: {firstline:"a", secondline:"b"}})

错误-

Property values can only be of primitive types or arrays thereof

推荐答案

可以将地图添加为属性.您应该将Address创建为单独的节点,然后使用Person创建relationship.或将地址作为property array添加到Person,例如

It is not possible to add map as a property. You should either create Address as a separate node and create a relationship with the Person. Or add the address as a property array to the Person, eg.,

(a:Person {name: "ABC", address: ["a", "b"]})

当然,您稍后将不得不将该数组转换回应用程序中的某个位置,以获取您最初想要的地图.

Of course, you would later have to convert that array back somewhere in your application to get the map you originally wanted.

这篇关于将地图添加为节点或关系中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 02:00