I am attempting to take a list of values and add to a field, but the manual is so vague and only uses the return clause to show List & maps, but nothing on how to for instance use the SET clause to actually assign it to a field on a node.
So here is an example of what I am trying to achieve.
SET gd.Postcode = "1234 HA"
SET gd.City = "London"
SET gd.URL = "https://somewhere.com"
SET gd.Telfoon = "03-6336000"
SET gd.Fax = "02344-6515328"
SET gd.BankAccounts = [{ABN-AMRO:"NL56 ABNA 123.456.780}, {ING:123.456.789}]
I can't get the bank account assignment to work. I would like to have a series of bank accounts in a list.
What error are you receiving? It looks like you have one ' " ' in [{ABN-AMRO:"NL56 ABNA 123.456.780}, {ING:123.456.789}] that could be causing an issue.
I got a similar error. I have been at it reading all over the internet for two days. The manual is also so vague.
The reason I wanted a list with key value pairs is because certain companies can have one bank account whilst others can have multiple, so it makes sense to have a list that I can call up.
So it seems a check of the manual would have been a good place for both of us
The property types:
Number , an abstract type, which has the subtypes Integer and Float
String
Boolean
The spatial type Point
Temporal types: Date , Time , LocalTime , DateTime , LocalDateTime and Duration
The adjective numeric , when used in the context of describing Cypher functions or expressions, indicates that any type of Number applies (Integer or Float).
Homogeneous lists of simple types can also be stored as properties, although lists in general (see Composite types) cannot be stored.It
Thank for finding that, but i still don't understand what it is pointing at. It seems just say that something is not possible, but not showing me what is and also what solution I can use for my situation.
So could you write the code that would work, because I am not grasping it.
It is that a company can have multiple bank accounts, so it is a variable amount. So when I write a query to the bank accounts I would like to just like to be presented all the bank accounts
What you want to do seems like it should be allowed but it is not.
What you can do, is convert your complex data structure into a string and store the string. And when you need a map, convert the string back into a complex data structure.
A Company having multiple Bank Accounts sounds very much like a bank account should be a node, with a relationship connecting them.
If you want the results back as a list of bank account properties for a given company, you can absolutely create a query to MATCH to what you need and return it in that format.
MATCH (u:User {id:'abc'})-[acct:HAS_ACCOUNT]->(bank:Bank)
RETURN u.id, bank.id, acct.account_id
This will get you most of the way there. If you need those 1 user per row with the map of bank/accounts there are some apoc functions that seem to do the trick. However, I'm not an APOC wizard so I will leave that to someone else.
Didn't think of it like that. See I was learning Python before I started learning NEO4j, so after undestanding data structures from PHP & Python, then seeing maps and lists here I figured the were also able to be a means of storage, But they seem to only be a means of presentation / collecting single pieces of nodal data fields.
You can store a simple list in a field, not a list that contains complex items in it. However, you can't create index the list's individual elements.
You can't store a map.
It's a bit of an engineering trade-off in terms of time and resources: do you want to make a system that can handle all the complexity you want? Or do focus your limited engineering resources on other things?
OTOH, this isn't necessarily a bad thing. It forces the schema designer to make a schema that's "cleaner". If you have a complex data structure stored in an attribute, it's hard to use the built-in Cypher language to access the individual components. But if the components are made into individual attributes, then you have the full power of Cypher.
For example, instead of list, why not have the items be nodes and have a relationships to those nodes? Those nodes can be indexed (for faster retrieval.) There may be other interrelationships between those nodes that could be interesting.
I think the theme of Neo4J is create the nodes and relationship so you can start making queries that would be difficult to make in SQL. You also have a lot of flexibility in Neo4J, so if your understanding changes, it's relatively simple to rejigger your schema (using APOC functions.)
Every language/system has its strong and weak points. You just have to pick the right tool for the right job.
I am just getting accustom to writing things out in such an atomic form. I am more accustom of normalisation norms from the Relational database aspect. Also the way that Python & PHP would do it is to allow / use nested data structures, such as nested list and using indexes to access them.
So I will look at your suggestion, but also as askd above, I would really like to see how to assign a list to a field.
In the movies database, the :ACTED_IN relationships have a roles property which is a list of strings.
As an example of setting it:
MATCH (:Person {name:'Keanu Reeves'})-[r:ACTED_IN]->(:Movie {title:'The Matrix'})
SET r.roles = ['Neo', 'Mr. Anderson']
That's for a list literal, you could also pass in a list of strings as a parameter, or assemble the list dynamically in Cypher. If you want to add to the list you can just use the + operation on the existing list:
MATCH (:Person {name:'Keanu Reeves'})-[r:ACTED_IN]->(:Movie {title:'The Matrix'})
SET r.roles += 'Mr. Anderson'
// or SET r.roles += ['Mr. Anderson']
Same result, the first approach appends an element to the exiting list and replaces the property. The second approach is combining two lists into one.