Comparing version 0.2.1 to 0.2.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var FlushRTIndexStatement_1 = require("./Statements/FlushRTIndexStatement"); | ||
var InsertReplaceStatement_1 = require("./Statements/InsertReplaceStatement"); | ||
@@ -48,2 +49,5 @@ var SelectStatement_1 = require("./Statements/SelectStatement"); | ||
}; | ||
QueryBuilder.prototype.flushRTIndex = function (index) { | ||
return new FlushRTIndexStatement_1.default(this.connection, index); | ||
}; | ||
QueryBuilder.prototype.truncate = function (rtIndex) { | ||
@@ -50,0 +54,0 @@ return new TruncateStatement_1.default(this.connection, rtIndex); |
@@ -10,8 +10,2 @@ "use strict"; | ||
} | ||
Sphinxql.prototype.getConnection = function () { | ||
return this.connection; | ||
}; | ||
Sphinxql.prototype.getQueryBuilder = function () { | ||
return new QueryBuilder_1.default(this.connection); | ||
}; | ||
Sphinxql.createConnection = function (params) { | ||
@@ -25,2 +19,8 @@ var client = new SphinxClient_1.default(params); | ||
}; | ||
Sphinxql.prototype.getConnection = function () { | ||
return this.connection; | ||
}; | ||
Sphinxql.prototype.getQueryBuilder = function () { | ||
return new QueryBuilder_1.default(this.connection); | ||
}; | ||
return Sphinxql; | ||
@@ -27,0 +27,0 @@ }()); |
{ | ||
"name": "sphinxql", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "SphinxQL query builder for Node.JS. Supports Sphinx search(2.x and 3.x) and Manticore search", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -57,2 +57,32 @@ # sphinxql | ||
### Establish Connection | ||
There are two possible ways of creating a connection between your application and the Manticore/Sphinx server. | ||
First and simplest is using the `createConnection` method. | ||
```javascript | ||
const { Sphinxql } = require('sphinxql'); | ||
const sphql = Sphinxql.createConnection({ | ||
host: 'localhost', | ||
port: 9306 | ||
}); | ||
``` | ||
The second option is using `createPoolConnection` method. This methodology allows you to have multiple open connections | ||
with Manticore/Sphinx reusing previous connections. To learn more about mysql2 connection pools (allowed parameters for | ||
the creation and configuration of the pool) read [mysql2 documentation about using connection pools](https://www.npmjs.com/package/mysql2#using-connection-pools). | ||
This technique uses more memory so be aware. | ||
```javascript | ||
const { Sphinxql } = require('sphinxql'); | ||
// Create the connection pool. The pool-specific settings are the defaults | ||
const sphql = Sphinxql.createPoolConnection({ | ||
host: 'localhost', | ||
port: 9306, | ||
waitForConnections: true, | ||
connectionLimit: 10, | ||
queueLimit: 0 | ||
}); | ||
``` | ||
### SELECT | ||
@@ -326,2 +356,18 @@ | ||
#### FLUSH RTINDEX (FlushRTIndexStatement) | ||
Read about [FLUSH RTINDEX](https://docs.manticoresearch.com/latest/html/sphinxql_reference/flush_rtindex_syntax.html) | ||
To use this statement see example below): | ||
```javascript | ||
connection.getQueryBuilder() | ||
.flushRTIndex('my_rt_index') | ||
.execute() | ||
.then((result, fields) => { | ||
console.log(result); | ||
}) | ||
.catch(err => { | ||
console.log(err); | ||
}); | ||
``` | ||
#### TRUNCATE RTINDEX (TruncateStatement) | ||
@@ -328,0 +374,0 @@ Read about [TRUNCATE RTINDEX](https://docs.manticoresearch.com/latest/html/sphinxql_reference/truncate_rtindex_syntax.html) in Manticore documantation |
import ClientInterface from './ClientInterface'; | ||
import FlushRTIndexStatement from './Statements/FlushRTIndexStatement'; | ||
import InsertStatement from './Statements/InsertReplaceStatement'; | ||
@@ -61,2 +62,6 @@ import SelectStatement from './Statements/SelectStatement'; | ||
public flushRTIndex(index: string): FlushRTIndexStatement { | ||
return new FlushRTIndexStatement(this.connection, index); | ||
} | ||
public truncate(rtIndex: string): TruncateStatement { | ||
@@ -63,0 +68,0 @@ return new TruncateStatement(this.connection, rtIndex); |
@@ -14,23 +14,9 @@ import ClientInterface from './ClientInterface'; | ||
/** | ||
* Returns the client connection instance. | ||
*/ | ||
public getConnection() : ClientInterface { | ||
return this.connection; | ||
} | ||
/** | ||
* Gets the query builder instance. Then you can start building | ||
* the query. | ||
*/ | ||
public getQueryBuilder() : QueryBuilder { | ||
return new QueryBuilder(this.connection); | ||
} | ||
/** | ||
* Creates a client connection and returns an instance of this class. | ||
* | ||
* @param params object containing | ||
* | ||
* @param params object containing configuration parameters | ||
*/ | ||
public static createConnection(params: object): Sphinxql { | ||
const client = new SphinxClient(params); | ||
return new Sphinxql(client); | ||
@@ -41,3 +27,3 @@ } | ||
* Creates a client pool connection and returns an instance of this class. | ||
* | ||
* | ||
* @param params an object containing the MySQL client connection properties | ||
@@ -47,4 +33,20 @@ */ | ||
const client = new SphinxClientPool(params); | ||
return new Sphinxql(client); | ||
} | ||
/** | ||
* Returns the client connection instance. | ||
*/ | ||
public getConnection() : ClientInterface { | ||
return this.connection; | ||
} | ||
/** | ||
* Gets the query builder instance. Then you can start building | ||
* the query. | ||
*/ | ||
public getQueryBuilder() : QueryBuilder { | ||
return new QueryBuilder(this.connection); | ||
} | ||
} |
@@ -31,2 +31,3 @@ import ClientInterface from '../ClientInterface'; | ||
this.truncate = true; | ||
return this; | ||
@@ -43,5 +44,5 @@ } | ||
} | ||
return expression; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
207780
140
3804
441