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

multiuser environment setDefaultLanguage break #17

Open
kalicki opened this issue Jan 29, 2019 · 1 comment
Open

multiuser environment setDefaultLanguage break #17

kalicki opened this issue Jan 29, 2019 · 1 comment

Comments

@kalicki
Copy link

kalicki commented Jan 29, 2019

Hey @alexsk, thanks for this plugin.

I have a problem with setDefaultLanguage for multiuser, your example dont work and setDefault for all models and not only this request by user.

// Set language
      Tag.find({}, function (_err, posts) {
        mongoose.setDefaultLanguage(lang);
        return res.status(200).send(posts);
      });

the last language set to be for everyone is the latest sent in lang

@kalicki kalicki changed the title multiuser environment setDefaultLanguage multiuser environment setDefaultLanguage break Jan 29, 2019
@kalicki
Copy link
Author

kalicki commented Jan 30, 2019

Async/Await, pseudo solution (maybe bad):

// Create query
      const elementRecipe = await Recipe.find(query.filter).sort(query.sort);

      // Set languages on values
      if (lang) {
        // return all elements only the lang requested
        elementRecipe.map(values => {
          values.setLanguage(lang);
        });
      }

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

No branches or pull requests

1 participant