shaxxo
April 20, 2016, 10:20pm
1
So I am using percolate:synced-cron package and I want to gain access to the collection. How do I do that ?
The collection name I set was cronHistory.
And I am trying to use the following code
conHistory.find({}).
But I am not able to get it work.
Any advice ?
if itâs not the spelling mistake on the collection name (conHistory), you need to explicitly export the variable name cronHistory in your package.js. Docs here , but would essentially be api.export(âcronHistoryâ).
shaxxo
April 20, 2016, 10:48pm
3
I looked at percolate:synced-cron package.js which has
api.export(âSyncedCronâ, âserverâ);
Based on that, I am trying to use the following
SyncedCron.cronHistory.find
still no luck!
shaxxo
April 20, 2016, 11:15pm
4
Figured it out, tried this
Package[âpercolate:synced-cronâ].SyncedCron._collection.find
1 Like
I have the same issue. How the heck can you gain access to the cronHistory collection??
Package[âpercolate:synced-cronâ].SyncedCron._collection.find just gives
TypeError: Cannot read property âfindâ of undefined
1 Like
Did you try:
import {SyncedCron} from 'meteor/percolate:synced-cron';
Meteor.startup(() => {
SyncedCron._collection.find();
});
This works on my side. The mongo collection is just part of the SyncedCron object. Importing it means you will have the collection aswell
Edit
Make sure that you rum your code in a Meteor.startup block. The SyncedCron package only adds the collection on startup not on initialization kf the package.
If I put your code in /server.main.js (and console.log the output)
import {SyncedCron} from âmeteor/percolate:synced-cronâ;
Meteor.startup(() => {
console.log(SyncedCron._collection.find({_id: 1}));
});
I get
{ _mongo:
I20171102-13:25:53.900(1)? { _observeMultiplexers: { â{âorderedâ:false,âcollectionNameâ:âusersSessionsâ,âselectorâ:{},âoptionsâ:{âtransformâ:null}}â: [Object] },
I20171102-13:25:53.901(1)? _onFailoverHook: { nextCallbackId: 1, callbacks: [Object], bindEnvironment: true },
I20171102-13:25:53.902(1)? db:
I20171102-13:25:53.903(1)? EventEmitter {
I20171102-13:25:53.905(1)? domain: null,
I20171102-13:25:53.906(1)? _events: {},
I20171102-13:25:53.908(1)? _eventsCount: 0,
I20171102-13:25:53.909(1)? _maxListeners: undefined,
I20171102-13:25:53.911(1)? s: [Object],
I20171102-13:25:53.912(1)? serverConfig: [Getter],
I20171102-13:25:53.914(1)? bufferMaxEntries: [Getter],
I20171102-13:25:53.915(1)? databaseName: [Getter] },
I20171102-13:25:53.917(1)? _primary: â127.0.0.1:3001â,
I20171102-13:25:53.920(1)? _oplogHandle:
I20171102-13:25:53.928(1)? { _oplogUrl: âmongodb://127.0.0.1:3001/localâ,
I20171102-13:25:53.931(1)? _dbName: âmeteorâ,
I20171102-13:25:53.932(1)? _oplogLastEntryConnection: [Object],
I20171102-13:25:53.934(1)? _oplogTailConnection: [Object],
I20171102-13:25:53.940(1)? _stopped: false,
I20171102-13:25:53.942(1)? _tailHandle: [Object],
I20171102-13:25:53.944(1)? _readyFuture: [Object],
I20171102-13:25:53.945(1)? _crossbar: [Object],
I20171102-13:25:53.948(1)? _baseOplogSelector: [Object],
I20171102-13:25:53.949(1)? _catchingUpFutures: [],
I20171102-13:25:53.949(1)? _lastProcessedTS: [Object],
I20171102-13:25:53.950(1)? _onSkippedEntriesHook: [Object],
I20171102-13:25:53.951(1)? _entryQueue: [Object],
I20171102-13:25:53.952(1)? _workerActive: false },
I20171102-13:25:53.952(1)? _docFetcher: { _mongoConnection: [Circular], _callbacksForCacheKey: {} } },
I20171102-13:25:53.953(1)? _cursorDescription:
I20171102-13:25:53.954(1)? { collectionName: âcronHistoryâ,
I20171102-13:25:53.955(1)? selector: { _id: 1 },
I20171102-13:25:53.956(1)? options: { transform: null } },
I20171102-13:25:53.957(1)? _synchronousCursor: null }
Is this correct? What do I do to retrieve actual data? How do I query this collection? I donât get it.
1 Like
import meteor/percolate:synced-cron
import { SyncedCron } from 'meteor/percolate:synced-cron';
retrieve data using query
data = SyncedCron._collection.find().fetch();
console.log("data", data)