I have stored the JSON data in ArangoDB collection in the following format.
{
"data": {
"1": [ {"db_name": "DSP"}, {"rel": "2"} ],
"2": [ {"rel_name": "DataSource"}, {"tuple": "201"}, {"tuple": "202"}, {"tuple": "203"} ],
"201": [ {"src_id": "Pos201510070"}, {"src_name": "Postgres"}, {"password": "root"}, {"host": "localhost"}, {"created_date": "20151007"}, {"user_name": "postgres"}, {"src_type": "Structured"}, {"db_name": "postgres"}, {"port": "None"} ],
"202": [ {"src_id": "pos201510060"}, {"src_name": "Postgres"},{"password": "root"}, {"host": "localhost"}, {"created_date": "20151006"}, {"user_name": "postgres"}, {"src_type": "Structured"}, {"db_name": "DSP"}, {"port": "5432"} ],
"203": [ {"src_id": "pos201510060"}, {"src_name": "Postgres"}, {"password": "root"}, {"host": "localhost"}, {"created_date": "20151006"}, {"user_name": "postgres"},{"src_type": "Structured"},{"db_name": "maindb"},{"port": "5432"} ]
}
}
I am new to ArangoDB. I have no idea about the storing and querying the data from ArangoDB. In my data there is no any predefined key, and the data get populated with time. My data is just like a semi-structured data which do not have any fixed number of attributes, and little bit complex due to its iterative list structure.
First, anyone can suggest me the best way for storing the above format in ArangoDB.
Second, I want to query this data in following manner: by specifying any key (not known in advance, by specifying it at runtime), or by specify combinations of key and value pair, e.g., Key1 == value1, or the combination using AND or OR logical operators like Key1 == value1 AND Key2 == value2 OR Key3== value3.
So, how we can iterate over the above data?
FOR doc IN collection LET attributes = ATTRIBUTES(doc.data) FOR attribute IN attributes RETURN { key: attribute, value: doc.data[attribute] }