-
Notifications
You must be signed in to change notification settings - Fork 5
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
Collection controller #133
Conversation
Codecov Report
@@ Coverage Diff @@
## 1.x #133 +/- ##
==========================================
- Coverage 89.04% 87.96% -1.08%
==========================================
Files 210 198 -12
Lines 4327 3615 -712
==========================================
- Hits 3853 3180 -673
+ Misses 440 409 -31
+ Partials 34 26 -8
Continue to review full report at Codecov.
|
collection/collection.go
Outdated
collection: dc, | ||
type ListOptions struct { | ||
Type string | ||
From int |
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.
from and size should be declared as int*
, so that the SDK can tell the difference between a non-setted option and any other value set by a user
collection/collection.go
Outdated
Size int | ||
} | ||
|
||
func NewListOptions(t string, from int, size int) *ListOptions { |
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.
the only constructor these "...Options" structures should allow are default constructors
and in Go this means that we don't need any constructor :)
this method should be removed
collection/create.go
Outdated
err := json.Unmarshal(res.Result, ack) | ||
if err != nil { | ||
return false, types.NewError(fmt.Sprintf("Unable to parse response: %s\n%s", err.Error(), res.Result), 500) | ||
return res.Error |
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.
nitpicking: this if
test is unnecessary as res.Error
can be returned directly
(this comment can be applied to all methods returning only an error or nil)
collection/exists.go
Outdated
return false, types.NewError(fmt.Sprintf("Unable to parse response: %s\n%s", err.Error(), res.Result), 500) | ||
} | ||
|
||
return true, nil |
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.
must return the parsed exists
value instead of a truthy value, as Kuzzle may return false
to tell the user that the requested collection does not exist
collection/get_mapping.go
Outdated
"github.com/kuzzleio/sdk-go/types" | ||
) | ||
|
||
// GetMapping retrieves the current mapping of the collection. | ||
func (dc *Collection) GetMapping(options types.QueryOptions) (*Mapping, error) { | ||
func (dc *Collection) GetMapping(index string, collection string) (string, error) { |
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.
must return a json.rawMessage
instead of a string
value
res, err := cToGoSearchResult(sr).FetchNext() | ||
return goToCSearchResult(sr.collection, res, err) | ||
} | ||
////export kuzzle_search_result_fetch_next |
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.
this file should be deleted instead of containing only commented code
types/search_options.go
Outdated
|
||
type SearchOptions struct { | ||
Type string | ||
From int |
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.
From
and Size
must be declared as int*
as we need a way to tell whether the option has been set or not
types/search_options.go
Outdated
Scroll string | ||
} | ||
|
||
func NewSearchOptions(t string, from int, size int, scroll string) *SearchOptions { |
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.
this constructor should be removed
types/search_result.go
Outdated
return sr | ||
} | ||
|
||
//// FetchNext returns a new SearchResult that corresponds to the next result page |
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.
please delete commented code
types/search_result.go
Outdated
sr.Options.SetFrom(options.From()) | ||
sr.Options.SetSize(options.Size()) | ||
} else { | ||
sr.Options.SetFrom(0) |
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.
from
and size
should not be defaulted to 0
Depends on #135 |
bd30d90
to
292f70b
Compare
292f70b
to
657c2cb
Compare
6e63d1e
to
b71f361
Compare
void create(char* index, char* collection)
void deleteSpecifications(char* index, char* collection)
bool exists(char* index, char* collection)
char* getMapping(char* index, char* collection)
char* getSpecifications(char* index, char* collection)
char* list(char* index, collectionListOptions*) // struct { enum{all, stored, realtime} type, int from, int size } collectionListOptions;
// not implemented (replaced by searchSpecifications + searchResult scroll ability): scrollSpecifications
*searchResult searchSpecifications(searchOptions* options)
void truncate(char* index, char *collection)
void updateMapping(char* index, char* collection, char* body)
char* updateSpecifications(char* index, char* collection, char* body)
bool validateSpecifications(char* body)