jkuester:remote-collections

v0.0.2Published 7 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Build Status Code Climate Test Coverage Issue Count

jkuester:remote-collections

Allows to subscribe and load data from remote collections via ddp, wrapped in manager class.

Usage

1import {RemoteCollections} from 'meteor/jkuester:remote-collections';
2
3const REMOTE_COLLECTION_1 = "some-remote-collection-id"; //you can use a hash fct if you want
4const REMOTE_URL_1 = 'http://localhost:3030';
5const REMOTE_METHOD_1 = 'ddp.getPrivateDatabases';
6const REMOTE_SUBS_METHOD_1 = 'ddp.getAvailableSubscriptions';
7
8//subscriptions must be put in startup
9Meteor.startup(()=>{
10    RemoteCollections.loadRemoteSubscriptions({id:REMOTE_COLLECTION_1, method:REMOTE_SUBS_METHOD_1});
11});
12
13
14//you can set debug mode to flood your console...
15//RemoteCollections.setDebug(true);
16
17//add a new ddp connection with a given id and url to listen
18RemoteCollections.addDDPConnectionURL(REMOTE_COLLECTION_1, REMOTE_URL_1);
19
20//load the collections by a given method name
21//the method should exist in the external app at {REMOTE_URL_1} and return a list of collection names
22//those collections will be fetched and loaded
23//you can pass an optional observe object to observe your subsribed actions on the external db
24RemoteCollections.loadRemoteCollections({id:REMOTE_COLLECTION_1, method:REMOTE_METHOD_1, observe:{}});
25
26//you can retrieve the collections from the class and...
27MY_REMOTE_COLLECTIONS = RemoteCollections.getCollections();
28
29//..add your collections to other services
30for(let key in MY_REMOTE_COLLECTIONS){
31   //do something with your collections
32}
33

Licence

MIT Licence, see licence file.