- 
                Notifications
    You must be signed in to change notification settings 
- Fork 17
Add specification CRUDL routes #231
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
          
     Merged
      
      
    
      
        
          +584
        
        
          −2
        
        
          
        
      
    
  
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            4 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      3fb6dd3
              
                Add specification CRUDL routes
              
              
                samniisan 2d099f1
              
                Merge remote-tracking branch 'origin/5.x' into 3-data-validation
              
              
                samniisan 0646935
              
                Updated the deleteSpecifications return type
              
              
                samniisan 0b04447
              
                Changed deleteSpecifications return type
              
              
                samniisan File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -249,6 +249,32 @@ Collection.prototype.deleteDocument = function (arg, options, cb) { | |
| return this; | ||
| }; | ||
|  | ||
| /** | ||
| * Deletes the current specifications of this collection | ||
| * | ||
| * @param {object} [options] - Optional parameters | ||
| * @param {responseCallback} [cb] - Handles the query response | ||
| * @return {object} this | ||
| */ | ||
| Collection.prototype.deleteSpecifications = function (options, cb) { | ||
| var | ||
| data = { index: this.index, collection: this.collection }, | ||
| self = this; | ||
|  | ||
| if (!cb && typeof options === 'function') { | ||
| cb = options; | ||
| options = null; | ||
| } | ||
|  | ||
| data = self.kuzzle.addHeaders(data, this.headers); | ||
|  | ||
| self.kuzzle.query(this.buildQueryArgs('collection', 'deleteSpecifications'), data, options, function (err, res) { | ||
| cb(err, err ? undefined : res.result); | ||
| }); | ||
|  | ||
| return self; | ||
| }; | ||
|  | ||
| /** | ||
| * Returns a boolean indicating whether or not a document with provided ID exists. | ||
| * | ||
|  | @@ -553,6 +579,30 @@ Collection.prototype.mUpdateDocument = function (documents, options, cb) { | |
| return self; | ||
| }; | ||
|  | ||
| /** | ||
| * Retrieves the current specifications of this collection | ||
| * | ||
| * @param {object} [options] - Optional parameters | ||
| * @param {responseCallback} cb - Handles the query response | ||
| */ | ||
| Collection.prototype.getSpecifications = function (options, cb) { | ||
| var | ||
| data = { index: this.index, collection: this.collection }, | ||
| self = this; | ||
|  | ||
| if (!cb && typeof options === 'function') { | ||
| cb = options; | ||
| options = null; | ||
| } | ||
|  | ||
| self.kuzzle.callbackRequired('Collection.getSpecifications', cb); | ||
| data = self.kuzzle.addHeaders(data, this.headers); | ||
|  | ||
| self.kuzzle.query(this.buildQueryArgs('collection', 'getSpecifications'), data, options, function (err, res) { | ||
| cb(err, err ? undefined : res.result); | ||
| }); | ||
| }; | ||
|  | ||
| /** | ||
| * Publish a realtime message | ||
| * | ||
|  | @@ -752,6 +802,68 @@ Collection.prototype.scroll = function (scrollId, options, filters, cb) { | |
| return this; | ||
| }; | ||
|  | ||
| /** | ||
| * Retrieves next result of a search with scroll query. | ||
| * | ||
| * @param {string} scrollId | ||
| * @param {object} [options] - Optional parameters | ||
| * @param {responseCallback} cb - Handles the query response | ||
| */ | ||
| Collection.prototype.scrollSpecifications = function (scrollId, options, cb) { | ||
| var | ||
| data = { scrollId: scrollId }; | ||
|  | ||
| if (!scrollId) { | ||
| throw new Error('Collection.scrollSpecifications: scrollId is required'); | ||
| } | ||
|  | ||
| if (!cb && typeof options === 'function') { | ||
| cb = options; | ||
| options = {}; | ||
| } | ||
|  | ||
| this.kuzzle.callbackRequired('Collection.scrollSpecifications', cb); | ||
|  | ||
| if (options && options.scroll) { | ||
| data.scroll = options.scroll; | ||
| } | ||
|  | ||
| this.kuzzle.query( | ||
| { controller: 'collection', action: 'scrollSpecifications'}, | ||
| this.kuzzle.addHeaders(data, this.headers), | ||
| options, | ||
| function (err, res) { | ||
| cb (err, err ? undefined : res.result); | ||
| } | ||
| ); | ||
| }; | ||
|  | ||
| /** | ||
| * Searches specifications across indexes/collections according to the provided filters | ||
| * | ||
| * @param {object} [filters] - Optional filters in ElasticSearch Query DSL format | ||
| * @param {object} [options] - Optional parameters | ||
| * @param {responseCallback} cb - Handles the query response | ||
| */ | ||
| Collection.prototype.searchSpecifications = function (filters, options, cb) { | ||
| 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. Other search methods return a KuzzleSearchResult object, shouldn't this one do the same? | ||
| var | ||
| data = { body: { query: filters } }, | ||
| self = this; | ||
|  | ||
| if (!cb && typeof options === 'function') { | ||
| cb = options; | ||
| options = {}; | ||
| } | ||
|  | ||
| self.kuzzle.callbackRequired('Collection.searchSpecifications', cb); | ||
|  | ||
| data = self.kuzzle.addHeaders(data, this.headers); | ||
|  | ||
| self.kuzzle.query({ controller: 'collection', action: 'searchSpecifications' }, data, options, function (err, res) { | ||
| cb(err, err ? undefined : res.result); | ||
| }); | ||
| }; | ||
|  | ||
| /** | ||
| * Subscribes to this data collection with a set of filters. | ||
| * To subscribe to the entire data collection, simply provide an empty filter. | ||
|  | @@ -847,6 +959,65 @@ Collection.prototype.updateDocument = function (documentId, content, options, cb | |
| return self; | ||
| }; | ||
|  | ||
| /** | ||
| * Updates the current specifications of this collection | ||
| * | ||
| * @param {object} specifications - Specifications content | ||
| * @param {object} [options] - Optional parameters | ||
| * @param {responseCallback} [cb] - Handles the query response | ||
| * @return {object} this | ||
| */ | ||
| Collection.prototype.updateSpecifications = function (specifications, options, cb) { | ||
| var | ||
| collection = {}, | ||
| data = { body: {} }, | ||
| self = this; | ||
|  | ||
| collection[this.collection] = specifications; | ||
| data.body[this.index] = collection; | ||
|  | ||
| if (!cb && typeof options === 'function') { | ||
| cb = options; | ||
| options = null; | ||
| } | ||
|  | ||
| data = self.kuzzle.addHeaders(data, this.headers); | ||
|  | ||
| self.kuzzle.query(this.buildQueryArgs('collection', 'updateSpecifications'), data, options, cb && function (err, res) { | ||
| cb(err, err ? undefined : res.result); | ||
| }); | ||
|  | ||
| return self; | ||
| }; | ||
|  | ||
| /** | ||
| * Validates the provided specifications | ||
| * | ||
| * @param {object} specifications - Specifications content | ||
| * @param {object} [options] - Optional parameters | ||
| * @param {responseCallback} cb - Handles the query response | ||
| */ | ||
| Collection.prototype.validateSpecifications = function (specifications, options, cb) { | ||
| var | ||
| collection = {}, | ||
| data = { body: {} }, | ||
| self = this; | ||
|  | ||
| collection[this.collection] = specifications; | ||
| data.body[this.index] = collection; | ||
|  | ||
| if (!cb && typeof options === 'function') { | ||
| cb = options; | ||
| options = null; | ||
| } | ||
|  | ||
| self.kuzzle.callbackRequired('Collection.validateSpecifications', cb); | ||
| data = self.kuzzle.addHeaders(data, this.headers); | ||
|  | ||
| self.kuzzle.query(this.buildQueryArgs('collection', 'validateSpecifications'), data, options, function (err, res) { | ||
| cb(err, err ? undefined : res.result.valid); | ||
| }); | ||
| }; | ||
|  | ||
| /** | ||
| * Instantiate a new Document object. Workaround to the module.exports limitation, preventing multiple | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
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.
Other scroll methods return a KuzzleSearchResult object, shouldn't this one do the same?