Support subdocument arrays
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.
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/aheckmann/mongoose-keywordize/issues/5 .
Aaron @aaronheckmann https://twitter.com/#!/aaronheckmann soundcloud.com/ajhecky github.com/aheckmann