Charles-olivier Demers
Charles-olivier Demers

Reputation: 1058

Meteor subscription is really slow

Currently I have a pub/sub with Meteor. On my react-native app, I subscribe to a subscription.

The subscription only does something like collection.find() But the time I got the ready state for the subscription is really long. The collection only has 330 documents.

Here's my publication:

Meteor.publish("clients", () => clients.find());

Is it normal?

Thank you

Upvotes: 0

Views: 508

Answers (1)

Thusila Bandara
Thusila Bandara

Reputation: 293

Below is a sample code that I have used.You can get and idea by looking at it.If you just publish your data, it will affect to your performance.

Meteor.publish('AllCustomers', function(search, hoid, options){

    // Prepare options
    options = _.extend({
        sort: {name: 1},
        skip: 0,
        limit: 10
    }, options);

    let query      = {}

    if ( search ) {
        let regex = new RegExp( search, 'i' );

        query = { 'headofficeId':hoid,
        $or: [
        { name: regex },
        { telNo: regex }
        ]
    };

    }else{
       query = {'headofficeId':hoid};
    }

return Customers.find( query, options );
});

Upvotes: 0

Related Questions