Skip to content
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

Apply automatic formatting via prettier #237

Merged
merged 1 commit into from
Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"trailingComma": "es5",
"arrowParens": "always",
"endOfLine": "lf"
}
30 changes: 15 additions & 15 deletions examples/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Add documents into the Solr index.
*/

// Use `var solr = require('solr-client')` in your code
var solr = require('./../lib/solr');
// Use `var solr = require('solr-client')` in your code
var solr = require('./../lib/solr');

// Create a client
var client = solr.createClient();
Expand All @@ -12,20 +12,20 @@ var client = solr.createClient();
client.autoCommit = true;

var docs = [];
for(var i = 0; i <= 10 ; i++){
var doc = {
id : 12345 + i,
title_t : "Title "+ i,
description_t : "Text"+ i + "Alice"
}
docs.push(doc);
for (var i = 0; i <= 10; i++) {
var doc = {
id: 12345 + i,
title_t: 'Title ' + i,
description_t: 'Text' + i + 'Alice',
};
docs.push(doc);
}

// Add documents
client.add(docs,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
client.add(docs, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});
20 changes: 10 additions & 10 deletions examples/addRemoteResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Add remote resource into the Solr index.
*/

// Use `var solr = require('solr-client')` in your code
// Use `var solr = require('solr-client')` in your code
var solr = require('./../lib/solr');

// Create a client
Expand All @@ -12,13 +12,13 @@ var client = solr.createClient();
client.autoCommit = true;

var options = {
path : '/home/lbdremy/Downloads/merchant-directory.csv',
format : 'csv'
}
client.addRemoteResource(options,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
path: '/home/lbdremy/Downloads/merchant-directory.csv',
format: 'csv',
};
client.addRemoteResource(options, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});
44 changes: 22 additions & 22 deletions examples/atomicUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ var client = solr.createClient();
client.autoCommit = true;

var doc = {
id : 12357,
title_t : "Original Title"
small_l : 12,
description_t : "Some Description"
}
id: 12357,
title_t: 'Original Title',
small_l: 12,
description_t: 'Some Description',
};

// Add documents
client.add(doc,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
client.add(doc, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});

var updateDoc = {
id : 12357,
title_t : { "set" : "Modified Title" },
small_l : { "inc" : 2 }
}
id: 12357,
title_t: { set: 'Modified Title' },
small_l: { inc: 2 },
};

// Add documents
client.atomicUpdate(doc,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
});
client.atomicUpdate(doc, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});
28 changes: 17 additions & 11 deletions examples/basicAuth.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
/**
* Use Basic HTTP Authentication to communicate with the Solr server.
* Use Basic HTTP Authentication to communicate with the Solr server.
*/

// Use `var solr = require('solr-client')` in your code
// Use `var solr = require('solr-client')` in your code
var solr = require('./../lib/solr');

var client = solr.createClient();
client.basicAuth('admin','passtest');
client.basicAuth('admin', 'passtest');

// Use `client.unauth` if you want to remove credentials previously set.
//client.unauth();

// You can now search documents using your credentials
var query = client.createQuery().q('laptop').dismax().qf({title_t : 0.2 , description_t : 3.3}).mm(2).start(0).rows(10);
client.search(query,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
var query = client
.createQuery()
.q('laptop')
.dismax()
.qf({ title_t: 0.2, description_t: 3.3 })
.mm(2)
.start(0)
.rows(10);
client.search(query, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});

24 changes: 12 additions & 12 deletions examples/commit.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
/**
* Commit your changes in the index with or without options.
* Commit your changes in the index with or without options.
*/

// Use `var solr = require('solr-client')` in your code
// Use `var solr = require('solr-client')` in your code
var solr = require('./../lib/solr');

var client = solr.createClient();

// Commit your changes without options
client.commit(function(err,res){
if(err) console.log(err);
if(res) console.log(res);
client.commit(function (err, res) {
if (err) console.log(err);
if (res) console.log(res);
});

// Commit your changes with `waitSearcher` options.
var options = {
waitSearcher: false
waitSearcher: false,
};
client.commit(options,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
client.commit(options, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});
28 changes: 15 additions & 13 deletions examples/createAddStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ client.autoCommit = true;

// Save all the products in the csv file into the database
fs.createReadStream(__dirname + '/materials/products.csv')
.on('error',onerror)
.pipe(csv.createStream({
escapeChar : '"', // default is an empty string
enclosedChar : '"' // default is an empty string
}))
.on('error',onerror)
.pipe(client.createAddStream())
.on('error',onerror)
.on('end',function(){
console.log('all products are in the database now.');
});
.on('error', onerror)
.pipe(
csv.createStream({
escapeChar: '"', // default is an empty string
enclosedChar: '"', // default is an empty string
})
)
.on('error', onerror)
.pipe(client.createAddStream())
.on('error', onerror)
.on('end', function () {
console.log('all products are in the database now.');
});

// Error handler
function onerror(err){
console.error(err);
function onerror(err) {
console.error(err);
}
19 changes: 9 additions & 10 deletions examples/delete.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Delete set of documents
* Delete set of documents
*/

// Use `var solr = require('solr-client')` in your code
// Use `var solr = require('solr-client')` in your code
var solr = require('./../lib/solr');

var client = solr.createClient();
Expand All @@ -11,11 +11,10 @@ var field = 'id';
var query = '*'; // Everything !Dangerous!

// Delete every documents
client.delete(field,query,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
});

client.delete(field, query, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
});
16 changes: 8 additions & 8 deletions examples/deleteAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ var solr = require('./../lib/solr');

var client = solr.createClient();

client.deleteAll(function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
// Do not forget to commit now
// to see the changes
client.deleteAll(function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
// Do not forget to commit now
// to see the changes
});
17 changes: 8 additions & 9 deletions examples/deleteByID.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ var solr = require('./../lib/solr');
var client = solr.createClient();

var id = 38738;
client.deleteByID(id,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
// Do not forget to commit now
// to see the changes
client.deleteByID(id, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
// Do not forget to commit now
// to see the changes
});

18 changes: 8 additions & 10 deletions examples/deleteByQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ var solr = require('./../lib/solr');
var client = solr.createClient();

var query = 'title_t:Hello';
client.deleteByQuery(query,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
// Do not forget to commit now
// to see the changes
client.deleteByQuery(query, function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
// Do not forget to commit now
// to see the changes
});


27 changes: 15 additions & 12 deletions examples/deleteByRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,19 @@ var solr = require('./../lib/solr');
var client = solr.createClient();

var startOffset = new Date();
start.setDate(start.getDate() -1);
start.setDate(start.getDate() - 1);
var stopOffset = new Date();
client.deleteByRange('last_update',startOffset,stopOffset,function(err,obj){
if(err){
console.log(err);
}else{
console.log(obj);
}
// Do not forget to commit now
// to see the changes
});


client.deleteByRange(
'last_update',
startOffset,
stopOffset,
function (err, obj) {
if (err) {
console.log(err);
} else {
console.log(obj);
}
// Do not forget to commit now
// to see the changes
}
);
Loading