Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jankapunkt/meteor-remote-collections-provider
Provides functionality to manage methods, collections and publications for the jokester:remote-collections package.
https://github.com/jankapunkt/meteor-remote-collections-provider
collections ddp meteor methods publication remote-connection subscription
Last synced: 6 days ago
JSON representation
Provides functionality to manage methods, collections and publications for the jokester:remote-collections package.
- Host: GitHub
- URL: https://github.com/jankapunkt/meteor-remote-collections-provider
- Owner: jankapunkt
- License: mit
- Created: 2016-12-20T12:17:50.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-01T13:50:40.000Z (about 8 years ago)
- Last Synced: 2024-12-08T07:41:23.227Z (2 months ago)
- Topics: collections, ddp, meteor, methods, publication, remote-connection, subscription
- Language: JavaScript
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/jankapunkt/meteor-remote-collections-provider.svg?branch=master)](https://travis-ci.org/jankapunkt/meteor-remote-collections-provider)
[![Code Climate](https://codeclimate.com/github/jankapunkt/meteor-remote-collections-provider/badges/gpa.svg)](https://codeclimate.com/github/jankapunkt/meteor-remote-collections-provider)
[![Test Coverage](https://codeclimate.com/github/jankapunkt/meteor-remote-collections-provider/badges/coverage.svg)](https://codeclimate.com/github/jankapunkt/meteor-remote-collections-provider/coverage)
[![Issue Count](https://codeclimate.com/github/jankapunkt/meteor-remote-collections-provider/badges/issue_count.svg)](https://codeclimate.com/github/jankapunkt/meteor-remote-collections-provider)# jkuester:remote-collections-provider
This meteor package allows to manage the registration of methods, collections and publications to be used by [jkuester:remote-collections](https://github.com/jankapunkt/meteor-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](https://github.com/jankapunkt/meteor-remote-collections)) or a custom DDP based implementation.
The RemoteCollectionsProvider is a singleton and can be imported and initialized via:
```javascrit
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:
```javascript
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).
```javascript
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:
```javascript
//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
```javascript
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