sqlite-search
v4.1.0
Published
automated sqlite text indexing via streams
Downloads
7
Readme
sqlite-search
api
require('sqlite-search')(opts, readyCallback)
opts
:
path
- required - the path to where the sqlite db should be stored/read fromcolumns
- required - an array of columns, e.g.['foo', 'bar']
to use as the schema for the search tableprimaryKey
- required - the primary key that will be passed tosince
and will by default order the column
readyCallback
Will get called with err, instance
var sqliteSearch = require('sqlite-search')
sqliteSearch(opts, function (err, searcher) {
searcher.createSearchStream(searchOpts)
})
instance.createWriteStream()
returns a writable object stream. objects written into this stream will be stored in the search table. make sure the keys of your object were included in the columns
array you passed into the constructor above
instance.createSearchStream(opts)
returns a readable object stream that emits search result objects
opts
:
field
- required - which column to search againstquery
- required - the search query string, passed toMATCH
select
- an array of strings to use as the select arguments, e.g.['foo', 'bar']
tranlates intoSELECT foo, bar
. defaults to*
if not specifiedorder
-ORDER BY ?
(default primaryKey)since
- if supplied will put in anAND ? > ?
with[since, primaryKey]
to the querylimit
-LIMIT ?
offset
-OFFSET ?
statement
- optionally you can specify a full SQL statement to run as the query. if specified all other options will be ignoredformatType
- if set to 'object' will format the search response as JSON for streaming. See https://github.com/maxogden/npm-readme-search for an example.