Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Supports determines the MongoDB nodes from which to read. #56

Merged
merged 3 commits into from
Dec 3, 2019

Conversation

chazepps
Copy link
Contributor

@chazepps chazepps commented Dec 2, 2019

Hi 😃

New feature supports .read(pref, tags) for load balancing.

    const options: any = {
      lean: true,
      limit: 10,
      offset: 0,
      page: 1,
      populate: ['images', 'comments'],
      read: {
        pref: 'secondary'
      }
    };

    const articles = await Article.paginate({}, options);

    res.send(articles);

ref: https://github.com/Automattic/mongoose/blob/master/lib/query.js#L1008

    /**
     * Determines the MongoDB nodes from which to read.
     * @param pref one of the listed preference options or aliases
     * @tags optional tags for this query
     */
    read(pref: string, tags?: any[]): this;

Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants