Skip to content

Commit

Permalink
fix: Fix deprecation warning for HasChildQuery.type
Browse files Browse the repository at this point in the history
`child_type` field in `has_child` query is deprecated.
Change `has_child>child_type` => `has_child>type`
Closes #13
  • Loading branch information
sudo-suhas committed Jul 10, 2017
1 parent d3cc094 commit 82058e3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/queries/joining-queries/has-child-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HasChildQuery extends JoiningQueryBase {
constructor(qry, type) {
super('has_child', ES_REF_URL, qry);

if (!isNil(type)) this._queryOpts.child_type = type;
if (!isNil(type)) this._queryOpts.type = type;
}

/**
Expand All @@ -52,7 +52,8 @@ class HasChildQuery extends JoiningQueryBase {
* @returns {HasChildQuery} returns `this` so that calls can be chained.
*/
type(type) {
return this.childType(type);
this._queryOpts.type = type;
return this;
}

/**
Expand All @@ -62,8 +63,8 @@ class HasChildQuery extends JoiningQueryBase {
* @returns {HasChildQuery} returns `this` so that calls can be chained.
*/
childType(type) {
this._queryOpts.child_type = type;
return this;
console.warn('[HasChildQuery] Field `child_type` is deprecated. Use `type` instead.');
return this.type(type);
}

/**
Expand Down

0 comments on commit 82058e3

Please sign in to comment.