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

intl string inside array #2

Open
ghost opened this issue Mar 30, 2016 · 3 comments
Open

intl string inside array #2

ghost opened this issue Mar 30, 2016 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 30, 2016

Hi, if in a mongoose schema I have an array field of objects with intl fields, how can be set the label translations inside this array? The set method described in documentation
post.set('title.all', { // defines all languages in one call using an object de: 'Another German title', fr: 'French title' });
applies to simple string fields not arrays.
Any help?

@alexsk alexsk added the question label Apr 2, 2016
@alexsk
Copy link
Owner

alexsk commented Apr 2, 2016

Array of objects with intl string fields works as expected using the following methods:

var librarySchema = new mongoose.Schema({
        books: [{ title: {type: String, intl: true}}],
});
var Library = mongoose.model('Library', librarySchema);

var lib = new Library();
lib.books.push({
    title: 'Default Language title'
});
lib.books[0].set('title.all', {
    en: 'English',
    de: 'German',
    fr: 'French'
});

while values can't be set/get using:

lib.books.set('0.title.all', {
    en: 'English',
    de: 'German',
    fr: 'French'
});
// or
lib.set('books.0.title.all', {
    en: 'English',
    de: 'German',
    fr: 'French'
});

That's a bug.

And the 2nd problem was found with arrays of strings:

var librarySchema = new mongoose.Schema({
    authors: [{type: String, intl: true}],
});
// or
var librarySchema = new mongoose.Schema({
    authors: {type: [String], intl: true},
});

It doesn't work at all here. Thank you for reporting on this.

@alexsk alexsk added the bug label Apr 2, 2016
@hb-github
Copy link

any solution here?

@PixsaOJ
Copy link

PixsaOJ commented Apr 8, 2022

@alexsk I see on your profile that you are from Ukraine, I hope you are doing good. Stay strong brother <3

this issue will wait.

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

No branches or pull requests

3 participants