Example #1
0
Meteor.publish('collectionCount', function (collectionName) {
  check(collectionName, String);
  checkAdminAccess.call(this);

  const collection = Mongo.Collection.get(collectionName);

  if (!collection) {
    this.error('non existing collection');
  }

  let cursor = collection.find({});
  let pollingInterval = 2 * 1000; // 2 sec

  return new Counter('collection-count', cursor, pollingInterval);
});
Example #2
0
Meteor.publish('collectionDocuments', function (collectionName, page = 1) {
  check(collectionName, String);
  check(page, Match.Maybe(Number));
  checkAdminAccess.call(this);

  const limit = 10;
  const skip = limit * (page - 1);
  const collection = Mongo.Collection.get(collectionName);

  if (!collection) {
    this.error('non existing collection');
  }

  return collection.find({}, {
    sort: { _id: 1 },
    limit,
    skip,
  });
});
 foundCollections.forEach((collection)=> {
   let exists = Mongo.Collection.get(collection.name);
   if (!exists) {
     new Mongo.Collection(collection.name);
   }
 });