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

Support subdocument arrays #5

Open
ragulka opened this issue Mar 5, 2014 · 1 comment
Open

Support subdocument arrays #5

ragulka opened this issue Mar 5, 2014 · 1 comment

Comments

@ragulka
Copy link

ragulka commented Mar 5, 2014

It would be great if this plugin would support subdocument arrays. Consider the following:

var pet = new Schema({
    name: String
  , kind: String
});

var child = new Schema({
    name: String
  , pets: [pet]
});

var schema = new Schema({
    name: { first: String, last: String }
  , tags: [String]
  , langs: [String]
  , kids: [child]
});

var opts = {};
opts.fields = ['name.first', 'name.last', 'langs', 'kids.name', 'kids.pets.name', 'kids.pets.kind'];

schema.plugin(keywordize, opts);
var Person = mongoose.model('Person', schema);

var person = new Person({
  name: { first: 'Aaron' },
  kids: [{ name: 'John', pets: [
    { name: 'betty', kind: 'cat' },
    { name: 'beethoven', kind: 'dog' }]
  }]
});

Currently, keywordize simply ignores any arrays of nested documents, but it would make sense to actually take them into account when generating keywords.

@aheckmann
Copy link
Collaborator

Good idea. I'll accept a pull request that adds support.

On Wednesday, March 5, 2014, ragulka [email protected] wrote:

It would be great if this plugin would support subdocument arrays.
Consider the following:

var pet = new Schema({
name: String
, kind: String});
var child = new Schema({
name: String
, pets: [pet]});
var schema = new Schema({
name: { first: String, last: String }
, tags: [String]
, langs: [String]
, kids: [child]});
var opts = {};opts.fields = ['name.first', 'name.last', 'langs', 'kids.name', 'kids.pets.name', 'kids.pets.kind'];
schema.plugin(keywordize, opts);var Person = mongoose.model('Person', schema);
var person = new Person({
name: { first: 'Aaron' },
kids: [{ name: 'John', pets: [
{ name: 'betty', kind: 'cat' },
{ name: 'beethoven', kind: 'dog' }]
}]});

Currently, keywordize simply ignores any arrays of nested documents, but
it would make sense to actually take them into account when generating
keywords.

Reply to this email directly or view it on GitHubhttps://github.com//issues/5
.

Aaron
@aaronheckmann https://twitter.com/#!/aaronheckmann
soundcloud.com/ajhecky
github.com/aheckmann

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

2 participants