# Can't create a node with nested sub-properties

**URL:** <https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744>\
**Category:** Cypher\
**Created:** [September 24, 2018, 8:05pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744 "2018-09-24T20:05:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dickersonc](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dickersonc/32/1216_2.png) [@dickersonc](https://community.neo4j.com/u/dickersonc)\
**Post date:** [September 24, 2018, 8:05pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/1 "2018-09-24T20:05:26Z")

</div>

I have searched everywhere, but cannot find the answer to this.

I need to create a node Config that has a Properties object with 2 key/value pairs (name and type). The keys, when queried, should end up as **properties.name** and **properties.type**. But I cannot seem to get the create syntax right. This is what I'm doing:

**CREATE (c1:Config) set c1.properties=[{name:"CiPipelineConfig1"}, {type:"test"}]**

But that gives me some weird error:

**Neo.ClientError.Statement.TypeError: Neo4j only supports a subset of Cypher types for storage as singleton or array properties.**

Can anyone help me figure this query out?

---

<div class="post-metadata">

**Author:** ![mike\_r\_black](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mike_r_black/32/30089_2.png) [@mike\_r\_black](https://community.neo4j.com/u/mike_r_black)\
**Post date:** [September 24, 2018, 9:02pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/2 "2018-09-24T21:02:57Z")

</div>

I could get this syntax to work but it may not be what you're looking for:

```auto
CREATE (c1:Config) 
SET c1.properties = ["CiPipelineConfig1","test"]
RETURN c1

```

I think you're going to get a lot of people wondering what the use case for storing your data this way instead of modeling it out in the graph.

---

<div class="post-metadata">

**Author:** ![dickersonc](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dickersonc/32/1216_2.png) [@dickersonc](https://community.neo4j.com/u/dickersonc)\
**Post date:** [September 24, 2018, 9:16pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/3 "2018-09-24T21:16:09Z")

</div>

So are you suggesting that every Property be a node, instead of being the payload of node??

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [September 24, 2018, 9:37pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/4 "2018-09-24T21:37:36Z")

</div>

Neo4j doesn't allow maps as properties (no sub-properties allowed, basically), and though lists are allowed as properties, they cannot be lists of maps (or lists of lists for that matter).

You can either use properties as-is on the node itself like `(c1:Config {name:"CiPipelineConfig1", type:"test"})`, or if you do need some means of grouping, create an additional connected node (or nodes) to hold the properties according to the grouping needed.

---

<div class="post-metadata">

**Author:** ![dickersonc](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/dickersonc/32/1216_2.png) [@dickersonc](https://community.neo4j.com/u/dickersonc)\
**Post date:** [September 24, 2018, 11:11pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/5 "2018-09-24T23:11:31Z")

</div>

What I meant to do was set each key/value pair separately, not as a map.

---

<div class="post-metadata">

**Author:** ![andrew\_bowman](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/andrew_bowman/32/73_2.png) [@andrew\_bowman](https://community.neo4j.com/u/andrew_bowman)\
**Post date:** [September 24, 2018, 11:15pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/6 "2018-09-24T23:15:00Z")

</div>

Oh, so you want to set an entire map's worth of properties at once?

That's easy enough:

```auto
WITH {name:"CiPipelineConfig1", type:"test", foo:"bar"} as props
CREATE (c1:Config)
SET c1 = props

```

This will overwrite all properties with the contents in the properties map. Complete description within the [Set section.](https://neo4j.com/docs/developer-manual/current/cypher/clauses/set/#set-remove-properties-using-empty-map) of the Cypher documentation.

If you instead want to add the properties (overwriting existing properties of the same name) but keep the rest of the properties, use `SET c1 += props`

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [September 25, 2018, 12:07pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/7 "2018-09-25T12:07:04Z")

</div>

Or if they are just stored but not frequently used you can store them as JSON string.  
APOC has a bunch of procedures/functions of automatically handling the conversions.

---

<div class="post-metadata">

**Author:** ![mike\_r\_black](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mike_r_black/32/30089_2.png) [@mike\_r\_black](https://community.neo4j.com/u/mike_r_black)\
**Post date:** [September 25, 2018, 3:03pm UTC](https://community.neo4j.com/t/cant-create-a-node-with-nested-sub-properties/1744/8 "2018-09-25T15:03:44Z")

</div>

This topic reminds me of a [Neo4j Blog Post about best and worst practices](https://neo4j.com/blog/dark-side-neo4j-worst-practices/). About a half way through the post it talks about storing blobs of data in Neo4j. Technically yes you could store very large strings, strings a of JSON even, but be weary of doing so. Neo4j is a graph database not a document database. If you have a need to store documents whose data doesn't make sense being stored as a graph, I'd recommend a polyglot persistence solution: store your graph data and in the properties of the nodes store the URL/ObjectId of that data. Then leverage other databases such as MongoDB or AWS S3 Buckets to store the actual document itself. A good example, a user's profile image. You'd want your user nodes but I'd store the JPG binary in an S3 bucket.
