meteor/validated-method

Wanted: validated-publication

johnslemmer opened this issue · 3 comments

Doesn't really belong on this project but not sure where else to put it.

But it would be nice to accomplish something that has a similar list benefits that validate method has:

  • Have an object that represents your publication. Refer to it through JavaScript scope rather than by a magic string name.

  • Built-in validation of arguments through aldeed:simple-schema, or roll your own argument validation.

  • Provide access to the same query that will be used inside the publication. Because of reasons described here I often times find myself copying and pasting a lot of the database queries.

  • Or even better than the above be able to do a single call that returns the subscription handler like before, but also, an already fetched list of the documents found. And have it be reactive. Ideally I could write in a ReactMeteorData container something like the following:

    export default createContainer(() => {
    const { handle, data } = publicationObject.subscribeAndFetch();
    return {
      loading: !handle.ready(),
      data: data,
    }
    }, 
    

When it comes down to it I feel like I copy the same pattern pretty often: subscribe, pass along the handle.ready() info, do the same query on the collection as happened in the publication, and pass along that data.

And oh yeah, obviously be able to handle compsite publications.

Would this be bad form to have something like this? It seems like it would be a great nice to have, just like validated-method is wonderful.

Someone made this and posted on the forum! If enough people try it and it's good we can make it more official.

I couldn't find it on the forum. I only found this.

So, I created my own. It is pretty much a copy and paste of validated method with the necessary changes. It doesn't have all the features that I want yet. But it does allow for composite publishing and having an object you can reference. I would love to add the ability to add sorting that only happens on the client side and of course the subscribeAndFetch. I don't have time for it now. But maybe someone else can take this and run with it.

I have found this package which seems to cover most common cases and shares the same structure that validated-method has. Is there any chance that it becomes a mdg package?

I think many of the points suggested here are included. Integrating it with a subsmanager on the client could be nice, but that seems more like a mixin package.