-
Notifications
You must be signed in to change notification settings - Fork 17
Add typescript support for search results #530
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
Changes from all commits
7e3ab76
496a6f6
f85fee6
9e90480
4839ea1
25c9488
72052fe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Profile } from '../security/Profile'; | ||
import { SearchResultBase } from './SearchResultBase'; | ||
|
||
export class ProfileSearchResult extends SearchResultBase<Profile> { | ||
constructor (kuzzle, request, options, response) { | ||
super(kuzzle, request, options, response); | ||
|
||
this._searchAction = 'searchProfiles'; | ||
this._scrollAction = 'scrollProfiles'; | ||
this.hits = response.hits.map(hit => ( | ||
new Profile(this._kuzzle, hit._id, hit._source) | ||
)); | ||
} | ||
|
||
next () { | ||
return super.next() | ||
.then((nextSearchResult: ProfileSearchResult) => { | ||
if (! nextSearchResult) { | ||
return null; | ||
} | ||
|
||
nextSearchResult.hits = nextSearchResult._response.hits.map(hit => ( | ||
new Profile(nextSearchResult._kuzzle, hit._id, hit._source) | ||
)); | ||
|
||
return nextSearchResult; | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
const { SearchResultBase } = require('./SearchResultBase'); | ||
import { SearchResultBase } from './SearchResultBase'; | ||
import { JSONObject } from '../../utils/interfaces'; | ||
|
||
class SpecificationsSearchResult extends SearchResultBase { | ||
export class SpecificationsSearchResult extends SearchResultBase<JSONObject> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know I should have created a proper |
||
|
||
constructor (kuzzle, query, options, response) { | ||
super(kuzzle, query, options, response); | ||
|
@@ -10,5 +11,3 @@ class SpecificationsSearchResult extends SearchResultBase { | |
this._scrollAction = 'scrollSpecifications'; | ||
} | ||
} | ||
|
||
module.exports = { SpecificationsSearchResult }; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { SearchResultBase } from './SearchResultBase'; | ||
import { User } from '../security/User'; | ||
|
||
export class UserSearchResult extends SearchResultBase<User> { | ||
|
||
constructor (kuzzle, query, options, response) { | ||
super(kuzzle, query, options, response); | ||
|
||
this._searchAction = 'searchUsers'; | ||
this._scrollAction = 'scrollUsers'; | ||
this.hits = this._response.hits.map(hit => ( | ||
new User(this._kuzzle, hit._id, hit._source) | ||
)); | ||
} | ||
|
||
next () { | ||
return super.next() | ||
.then((nextSearchResult: UserSearchResult) => { | ||
if (! nextSearchResult) { | ||
return null; | ||
} | ||
|
||
nextSearchResult.hits = nextSearchResult._response.hits.map(hit => ( | ||
new User(nextSearchResult._kuzzle, hit._id, hit._source) | ||
)); | ||
|
||
return nextSearchResult; | ||
}); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,3 @@ export class Profile { | |
options); | ||
} | ||
} | ||
|
||
module.exports = { Profile }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these writable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because in the
SpecificationSearchResult
class we overload the controller withcollection