Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Traverse references #133

Closed
amcsi opened this issue Dec 21, 2015 · 11 comments
Closed

Traverse references #133

amcsi opened this issue Dec 21, 2015 · 11 comments

Comments

@amcsi
Copy link

amcsi commented Dec 21, 2015

Would it be possible to allow being redirected to the target document if a value is a reference?

It would be so useful.

Apologies if there's already a way and I just didn't know; but when right clicking a reference value, the only option the context menu gives me is "Copy".

@dboissier
Copy link
Owner

Hi,

I was thinking about document navigation and it could be a cool feature. Perhaps we could work together on refining the use case.

What do you think about it?

@amcsi
Copy link
Author

amcsi commented Dec 22, 2015

Well when I very first even heard about MongoDB and saw that it worked on this Ref basis, my very first thought was that the point of this would be that you could easily traverse documents in both when coding and when just viewing the DB in a GUI client.

It's already possible to traverse the documents since I'm using Doctrine ODM for PHP; however if I just wanted to look around the documents when viewing the database, I'm unable to in most GUI MongoDB clients including this one.

A common use case I would have is that I have a collection of countries in the database (with a code, currency and name), and I have another collection of users. Each user can have a country associated with them. Now when reading the users collection in the database, sometimes I need to know which country that user is in. Unfortunately if I wanted to see what country the user is in, I have to manually copy the Ref ID, go to the countries table, find that ID, and then read it.
This would be much simpler if I could just traverse to the country on the spot (and also be able to go back quickly).

@amcsi
Copy link
Author

amcsi commented Dec 22, 2015

Here is an existing GUI client that gives you the possibility of viewing the target documents of references

http://3t.io/mongochef/

@dboissier
Copy link
Owner

Hi,

A schema is recommended to make the navigation work. Do you have any info on how it could be introduced in MongoDB?

@amcsi
Copy link
Author

amcsi commented Dec 22, 2015

@dboissier it's just a standard in MongoDB that these Refs in that format mean references to those documents. Internally there's nothing for this implementation-wise in MongoDB.

You already have all the data necessary to be able to do traversing. Any object containing the two mandatory properties of the DBRef standard can act as a ref: https://docs.mongodb.org/v3.0/reference/database-references/#format
You just need to allow with such an object value to be taken to the given ID document ($id) do of that given ($ref), optionally taken to that given DB ($db)

@dboissier
Copy link
Owner

Thanks for this info.

Actually, I never used this feature, so this is why I asked you ;)

@dboissier
Copy link
Owner

Hi,

In the new 0.10.0-SNAPSHOT available in the home page of the project, you can view the referenced document in a Dialog.
Select the DBRef in the view and right-click on View Reference. As alternative you can use the shortcut ⌘ + B.

Please tell me if it is fine or some improvement would be needed.

Thanks.

@amcsi
Copy link
Author

amcsi commented Nov 24, 2016

There is an exception I keep getting when viewing one of the references:

14:49	CodecConfigurationException: Can't find a codec for class com.mongodb.DBRef.


org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.DBRef.
	at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
	at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
	at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
	at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:174)
	at org.bson.codecs.DocumentCodec.writeIterable(DocumentCodec.java:197)
	at org.bson.codecs.DocumentCodec.writeValue(DocumentCodec.java:170)
	at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:189)
	at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131)
	at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45)
	at org.bson.Document.toJson(Document.java:294)
	at org.bson.Document.toJson(Document.java:268)
	at org.bson.Document.toJson(Document.java:255)
	at org.codinjutsu.tools.mongo.utils.MongoUtils.stringifyList(MongoUtils.java:109)
	at org.codinjutsu.tools.mongo.view.nodedescriptor.MongoKeyValueDescriptor$MongoKeyListValueDescriptor.getFormattedList(MongoKeyValueDescriptor.java:251)
	at org.codinjutsu.tools.mongo.view.nodedescriptor.MongoKeyValueDescriptor$MongoKeyListValueDescriptor.toString(MongoKeyValueDescriptor.java:247)
	at javax.swing.tree.DefaultMutableTreeNode.toString(DefaultMutableTreeNode.java:1244)
	at javax.swing.JTree.convertValueToText(JTree.java:1596)
	at javax.swing.tree.DefaultTreeCellRenderer.getTreeCellRendererComponent(DefaultTreeCellRenderer.java:428)
	at com.intellij.ui.treeStructure.treetable.TreeTableTree$1.getTreeCellRendererComponent(TreeTableTree.java:122)
	at javax.swing.plaf.basic.BasicTreeUI$NodeDimensionsHandler.getNodeDimensions(BasicTreeUI.java:2807)
	at javax.swing.tree.AbstractLayoutCache.getNodeDimensions(AbstractLayoutCache.java:492)
	at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.updatePreferredSize(VariableHeightLayoutCache.java:1360)
	at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.expand(VariableHeightLayoutCache.java:1496)
	at javax.swing.tree.VariableHeightLayoutCache$TreeStateNode.expand(VariableHeightLayoutCache.java:1288)
	at javax.swing.tree.VariableHeightLayoutCache.rebuild(VariableHeightLayoutCache.java:743)
	at javax.swing.tree.VariableHeightLayoutCache.setModel(VariableHeightLayoutCache.java:109)
	at javax.swing.plaf.basic.BasicTreeUI.setModel(BasicTreeUI.java:412)
	at javax.swing.plaf.basic.BasicTreeUI$Handler.propertyChange(BasicTreeUI.java:3414)
	at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
	at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
	at java.awt.Component.firePropertyChange(Component.java:8428)
	at javax.swing.JTree.setModel(JTree.java:882)
	at javax.swing.JTree.<init>(JTree.java:670)
	at com.intellij.ui.treeStructure.Tree.<init>(Tree.java:68)
	at com.intellij.ui.treeStructure.treetable.TreeTableTree.<init>(TreeTableTree.java:43)
	at com.intellij.ui.treeStructure.treetable.TreeTable.setModel(TreeTable.java:65)
	at com.intellij.ui.treeStructure.treetable.TreeTable.<init>(TreeTable.java:57)
	at org.codinjutsu.tools.mongo.view.JsonTreeTableView.<init>(JsonTreeTableView.java:77)
	at org.codinjutsu.tools.mongo.view.action.GoToMongoDocumentAction$MongoDocumentPanel.<init>(GoToMongoDocumentAction.java:81)
	at org.codinjutsu.tools.mongo.view.action.GoToMongoDocumentAction.actionPerformed(GoToMongoDocumentAction.java:57)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:156)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:211)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.a(ActionMenuItem.java:304)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:905)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:284)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.a(ActionMenuItem.java:112)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.access$300(TransactionGuardImpl.java:40)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:113)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:123)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:109)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:513)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:45)
	at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)
	at java.awt.Component.processMouseEvent(Component.java:6533)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
	at java.awt.Component.processEvent(Component.java:6298)
	at java.awt.Container.processEvent(Container.java:2236)
	at java.awt.Component.dispatchEventImpl(Component.java:4889)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
	at java.awt.Container.dispatchEventImpl(Container.java:2280)
	at java.awt.Window.dispatchEventImpl(Window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:795)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:627)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I also got this:

name can not be null
java.lang.IllegalArgumentException: name can not be null
	at com.mongodb.assertions.Assertions.notNull(Assertions.java:37)
	at com.mongodb.MongoDatabaseImpl.<init>(MongoDatabaseImpl.java:48)
	at com.mongodb.MongoClient.getDatabase(MongoClient.java:354)
	at org.codinjutsu.tools.mongo.logic.MongoManager$4.run(MongoManager.java:134)
	at org.codinjutsu.tools.mongo.logic.MongoManager$4.run(MongoManager.java:130)
	at org.codinjutsu.tools.mongo.logic.MongoManager.execute(MongoManager.java:167)
	at org.codinjutsu.tools.mongo.logic.MongoManager.findMongoDocument(MongoManager.java:142)
	at org.codinjutsu.tools.mongo.view.MongoPanel$1.getReferenceDocument(MongoPanel.java:86)
	at org.codinjutsu.tools.mongo.view.MongoResultPanel.getReferencedDocument(MongoResultPanel.java:319)
	at org.codinjutsu.tools.mongo.view.action.GoToMongoDocumentAction.actionPerformed(GoToMongoDocumentAction.java:52)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:197)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:156)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:211)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.a(ActionMenuItem.java:304)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:905)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:284)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.a(ActionMenuItem.java:112)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.access$300(TransactionGuardImpl.java:40)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:113)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:123)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:109)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:513)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:45)
	at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)
	at java.awt.Component.processMouseEvent(Component.java:6533)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
	at java.awt.Component.processEvent(Component.java:6298)
	at java.awt.Container.processEvent(Container.java:2236)
	at java.awt.Component.dispatchEventImpl(Component.java:4889)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
	at java.awt.Container.dispatchEventImpl(Container.java:2280)
	at java.awt.Window.dispatchEventImpl(Window.java:2746)
	at java.awt.Component.dispatchEvent(Component.java:4711)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at com.intellij.ide.IdeEventQueue.c(IdeEventQueue.java:795)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:627)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:387)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

But there's another reference which did work.

By the way amazing job with this so far, this is going to be tremendously helpful!
One other thing that would be great as well is being able to traverse the entire view to viewing the referenced document so you could keep traversing references. It's what you can do in MongoChef

@dboissier
Copy link
Owner

Hi,

I think about to keep the navigation within the view but I wanted to build something simple before going through it.

I fixed the first issue but the second is related to the DBRef. How is it structured?

@dboissier dboissier reopened this Nov 24, 2016
@dboissier
Copy link
Owner

The latest SNAPSHOT fixed the second issue with the DBRef

@dboissier
Copy link
Owner

Hi @amcsi,

the following build allow navigating between DBRef in the same view. You can move backward by clicking on the Back icon which appears in the top toolbar of the view.

If you have some idea to enhance the functionality, please feel free ;).

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants