Giter VIP home page Giter VIP logo

meteor-remote-collections-provider's Introduction

Build Status Code Climate Test Coverage Issue Count

jkuester:remote-collections-provider

This meteor package allows to manage the registration of methods, collections and publications to be used by jkuester:remote-collections or any other remote application via DDP.

Usage

The package is a handy tool, if you want to manage which collections are available to an external app (which may use jkuester:remote-collections) or a custom DDP based implementation.

The RemoteCollectionsProvider is a singleton and can be imported and initialized via:

import {RemoteCollectionsProvider} from "meteor/jkuester:remote-collections-provider";
RemoteCollectionsProvider.init();

Your remote application requires some information, to successfully get your collections:

  • What method can it call to get a list of available collections (their names)
  • What method can it call to get a list of available subscriptions (their names)

Therefore you first need to add your collections to the list of available collection:

RemoteCollectionsProvider.addCollectionNames('myMongoCollection'); //pass the name, you passed to the Mongo.Collection constructor

Then you need to add your publications (you do not need to call Meteor.publish, it does this for you, too).

RemoteCollectionsProvider.addPublication('myCollection.public', function(){
    return myCollection.find({}); //your code here
});

Finally you need to provide two methods, which allows your external app to retrieve the lists of available collections and subscriptions:

//ake all collection names available
RemoteCollectionsProvider.addMethod(
    "ddp.getAvailableRemoteMethods",
    function(){
        //returns a list of all available publications
        return RemoteCollectionsProvider.getAllCollectionNames();
    },
    //use true to call Meteor.methods(...) on this immediatly
    //you can also use false to bundle and the call RemoteCollectionsProvider.applyAllMethods()
    true
);


//make all subscription names available
RemoteCollectionsProvider.addMethod(
    "ddp.getAvailableRemotePublications",
    function(){
        //returns a list of all available publications
        return RemoteCollectionsProvider.getAllPublicationNames();
    },
    true
);

In your external application you can consume these functions via

const remote = DDP.connect(yourProviderAppUrl);
//...

const remoteCollections = remote.call("ddp.getAvailableRemoteMethods");
for(let collection of remoteCollections)
    //add collection...

const remotePublications = remote.call("ddp.getAvailableRemotePublications");
for(let publication of remotePublications)
    //subscribe...

Licence

MIT Licence, see Licence file

meteor-remote-collections-provider's People

Watchers

 avatar  avatar  avatar

meteor-remote-collections-provider's Issues

Allow to define only names

Allow to register pubs/methods also only by names.
(Allow this to be backwards compatible to the older versions)

Version 1.0

Major transition with the following features

  • minimal functionality (remove all clutter)

  • use in combination with an api.json file, that defines the api

  • provide functions to check, that changes in the app/service don't defy the api definitions

  • update tests

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.