import { check } from 'meteor/check';
import { Mongo } from 'meteor/mongo'
import Collections from '../../collections/worklist4hislink.js';
import { Counts } from 'meteor/tmeasday:publish-counts';

Meteor.publish("worklist4hislink", function({ brand, limit }) {

    if (brand == null) {
        return [];
    }
    if (!this.userId) {
        return this.ready();
    }
    const userid = this.userId;
    check(brand, String);
    check(limit, Number);
    Counts.publish(this, 'brandCount', Collections[brand].find(), { noReady: true });

    // let Worklist = new Mongo.Collection(brand);
    // console.log(Worklist.find({ _userid: userid, _devicemap: devicemap }).fetch())
    return Collections[brand].find({}, {
        disableOplog: true,
        // pollingThrottleMs: 1000,
        pollingIntervalMs: 1000,
        limit: limit
    });
});