msavin / Mongol-meteor-explore-minimongo-devtools

In-App MongoDB Editor for Meteor (Meteor DevTools)
http://play.with.meteor.toys
825 stars 40 forks source link

Local-only Collection Support? #73

Closed mastastealth closed 9 years ago

mastastealth commented 9 years ago

If I define a collection like so: local = new Mongo.Collection(null);

Mongol doesn't seem to grab it. Is there anyway to see this besides using the console?

JackAdams commented 9 years ago

Mongol won't find it by default, but you should be able to tell Mongol to look for it using the api here: https://github.com/msavin/Mongol/blob/master/documentation/COMPATIBILITY.md The docs suggest not using variable names, but try it anyway. I've got a feeling it might work:

Session.set("Mongol", {
    collections: ["local",<any other collections you want>]
})

I'll be interested to hear the results.

mastastealth commented 9 years ago

@JackAdams Ok, running that does add it to the list, and it seems to receive the correct count of items, however moving through the items continually spits out "Cannot read proper 'find' of undefined" with no data in the documents.

JackAdams commented 9 years ago

Hmm... yeah, I think I know why. This problem is fixable, but at the moment, it's something Mongol doesn't support. @msavin -- want me to work on a fix?

msavin commented 9 years ago

@JackAdams Not yet - lets wait for Meteor Toys

msavin commented 9 years ago

Update for @JackAdams: if you have time, that would be great :+1:

jordangarside commented 9 years ago

:+1:

JackAdams commented 9 years ago

I've added full local collection support to Constellation, but it took a pretty substantial refactor. I don't know whether you'd want me to take the knife to Mongol in the same way.

Basically, in each of the event handlers that is going to fire a server side mutator method, you need to:

  1. check whether the current collection is local and (assuming it is ...)
  2. replicate the intended method's action on the client only
  3. return without making the method call to the server

Here's an example for the "Duplicate" event handler from the Constellation codebase. There are similar bits of code for the delete and save methods, but the editable-json (0.5.7+) has its own mutator methods and local collection support, so no need to worry about that.

Local collection detection is here -- it's a pretty blunt instrument, but works for any local collections that are in the global scope.

msavin commented 9 years ago

Local collections will come in a future update for Mongol. In the meanwhile, I will close the thread since it is not as issue or advertised feature.