I am trying to store the network layout in couch db, but my solution provides a random graph. I store the nodes with a document:
{_ id, nodeName, group} and archive links in traditional: {_ ID, source_id, target_id, value} I have created a view after joining the Think DB and after several tutorials in many relationships:
function doctor) {if (doc.type == 'connection') {if (doc.source_id) emit ("source", {'_id': doc.source_id}); If (doc.target_id) emit ("target", {'_id': doc.target_id}); }} which should be indexed sequence of source and target ID, then I pass it in the list function with include_docs = true , it assumes That the source and target come together in the pair will tie everything back into a structure like this: {"nodes": [{"nodename": "name1", "group": "1 "," "Source": "source": "source": "," source ": 7," target ": 0," value ": 1}, {" source ": 7," name "," group ":" 1 "},]," link ": [However, in my list there is a proper JSON output, map sources Shows the number of docs rows and then target Docs. So far, I have no idea how this work works properly - I am happy to bring the extra value from the _id document in the list but I have not found any good examples so far. Welcome to alternative methods of achieving the same goal _id values are standard for sophiebecins so far. Update: While writing a question I came up with different views that solved my immediate problem, but I still want to see other options. Updated map:
function (doctor) {if (doc.type == 'connection') {if (doc.source_id) emit ([doc._id, 0, "source" ], {'_id': doc.source_id}); If (doc.target_id) emit ([doc._id, 1, "target"], {'_id': doc.target_id}); }}
Your updated map function makes more sense. However, you do not already have your key of 0 and 1 since "source" and "target" Code>.
Comments
Post a Comment