Skip to content

Commit

Permalink
Applied PR corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
Nataniel López committed Feb 17, 2020
1 parent f59f624 commit e73b7e0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Removes a document in a solr core
- model: `Model`: A model instance
- item: `Object`: The item to be removed

- Resolves `Boolean`: `true` if the operation was successful
- Rejects `SolrError`: When something bad occurs

### ***async*** `multiRemove(model, filters)`
Expand All @@ -254,6 +255,7 @@ Removes one or more documents in a solr core
- model: `Model`: A model instance
- filters: `Object`: Filters criteria to match documents

- Resolves `Boolean`: `true` if the operation was successful
- Rejects `SolrError`: When something bad occurs

### ***async*** `createSchema(model, core)`
Expand Down Expand Up @@ -466,9 +468,11 @@ const model = new Model();

// remove
await solr.remove(model, { id: 'some-id', field: 'value' });
// > true

// multiRemove
await solr.multiRemove(model, { field: { type: 'greater', value: 10 } });
// > true

// createSchema
await solr.createSchema(model);
Expand Down
2 changes: 1 addition & 1 deletion lib/config-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ConfigValidator {

const validConfig = configStruct(config);

if((validConfig.user && !validConfig.password) || (validConfig.password && !validConfig.user))
if(validConfig.user && !validConfig.password)
throw new Error(`Password required for user '${validConfig.user}'`);

return validConfig;
Expand Down
6 changes: 6 additions & 0 deletions lib/solr.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class Solr {
* Removes an item from the database
* @param {Model} model Model instance
* @param {Object} item The item to delete
* @returns {Boolean} true if the operation was successful
* @throws When something goes wrong
* @example
* await remove(model, { id: 'some-id', value: 'some-value' });
Expand All @@ -189,12 +190,15 @@ class Solr {
const res = await Request.post(endpoint, { delete: { id: item.id } }, this._auth);

Response.validate(res);

return true;
}

/**
* Multi remove items from the database
* @param {Model} model Model instance
* @param {Object} filters solr filters
* @returns {Boolean} true if the operation was successful
* @throws When something goes wrong
* @example
* await multiRemove(model, { myField: { type: 'greater', value: 10 } });
Expand All @@ -212,6 +216,8 @@ class Solr {
const res = await Request.post(endpoint, query, this._auth);

Response.validate(res);

return true;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/solr-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ describe('Solr', () => {
{ url: 'valid', core: 'valid', user: ['not a string'], password: 'valid' },
{ url: 'valid', core: 'valid', user: ['not a string'], password: ['not a string'] },
{ url: 'valid', core: 'valid', user: 'valid', password: ['not a string'] },
{ url: 'valid', core: 'valid', user: 'valid' },
{ url: 'valid', core: 'valid', password: 'valid' }
{ url: 'valid', core: 'valid', user: 'valid' }

].forEach(config => {

Expand Down

0 comments on commit e73b7e0

Please sign in to comment.