Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Commit

Permalink
Merge pull request #472 from patrick-rodgers/dev
Browse files Browse the repository at this point in the history
Fix for 462
  • Loading branch information
patrick-rodgers committed May 24, 2017
2 parents ca535bf + 290c660 commit acfb373
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions src/sharepoint/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,27 +220,27 @@ export class Search extends QueryableInstance {
formattedBody = query;

if (formattedBody.SelectProperties) {
formattedBody.SelectProperties = { results: query.SelectProperties };
formattedBody.SelectProperties = this.fixupProp(query.SelectProperties);
}

if (formattedBody.RefinementFilters) {
formattedBody.RefinementFilters = { results: query.RefinementFilters };
formattedBody.RefinementFilters = this.fixupProp(query.RefinementFilters);
}

if (formattedBody.SortList) {
formattedBody.SortList = { results: query.SortList };
formattedBody.SortList = this.fixupProp(query.SortList);
}

if (formattedBody.HithighlightedProperties) {
formattedBody.HithighlightedProperties = { results: query.HithighlightedProperties };
formattedBody.HithighlightedProperties = this.fixupProp(query.HithighlightedProperties);
}

if (formattedBody.ReorderingRules) {
formattedBody.ReorderingRules = { results: query.ReorderingRules };
formattedBody.ReorderingRules = this.fixupProp(query.ReorderingRules);
}

if (formattedBody.Properties) {
formattedBody.Properties = { results: query.Properties };
formattedBody.Properties = this.fixupProp(query.Properties);
}

const postBody = JSON.stringify({
Expand All @@ -251,6 +251,20 @@ export class Search extends QueryableInstance {

return this.post({ body: postBody }).then((data) => new SearchResults(data, this.toUrl(), query));
}

/**
* Fixes up properties that expect to consist of a "results" collection when needed
*
* @param prop property to fixup for container struct
*/
private fixupProp(prop: any): any {

if (prop.hasOwnProperty("results")) {
return prop;
}

return { results: prop };
}
}

/**
Expand Down Expand Up @@ -321,9 +335,9 @@ export class SearchResults {
});

// we have reached the end
if (query.StartRow > this.TotalRows) {
return Promise.resolve(null);
}
// if (query.StartRow > this.TotalRows) {
// return Promise.resolve(null);
// }

const search = new Search(this._url, null);
return search.execute(query);
Expand Down

0 comments on commit acfb373

Please sign in to comment.