Home Reference Source
import IFTSTransaction from 'indexedfts/lib/Transaction.js'
public class | source

IFTSTransaction

Transaction.

Almost methods are the same interface as IndexedFTS and IFTSArrayPromise. Probably this class is faster than other classes in most cases.

Please be careful, IFTSTransaction are sometimes makes a big cache. Should not keep many transactions if not need.

Constructor Summary

Public Constructor
public

constructor(db: IndexedFTS, transaction: IDBTransaction)

Member Summary

Public Members
public

db: IndexedDB

public

promise: Promise<IndexedDB>

Promise for await closing transaction.

public

transaction: IDBTransaction

Method Summary

Public Methods
public

between(column: object, lower: object, upper: object): IFTSArrayPromise

Get contents that have property is between argument values.

public

Delete contents from database.

public

equals(column: object, value: object): IFTSArrayPromise

Get contents that have fully matched property.

public

filter(fun: function(content: object, index: Number): object): IFTSArrayPromise

Filtering elements by function and returns IFTSArrayPromise.

public

Get content by primary key.

public

Get all contents.

public

getNGrams(column: string, options: object): Promise<Map<string, number>>

Get N-Gram set from index.

public

getWords(column: string, options: object): Promise<Map<string, number>>

Get word set from index.

public

Get contents that have property greater than value.

public

Get contents that have property greater than value or equals value.

public

lower(column: object, value: object): IFTSArrayPromise

Get contents that have property lower than value.

public

Get contents that have property lower than value or equals value.

public

map(fun: function(content: object, index: Number): object): IFTSArrayPromise

Do something process for each elements and returns IFTSArrayPromise.

public

Put contents into database.

public

search(columns: object | object[], query: string, options: object): IFTSArrayPromise

Get contents that have matched property by full-text search.

public

searchWord(columns: object | object[], query: string, options: object): IFTSArrayPromise

Find contents that have fully matched word in property.

public

sort(column: object, order: 'asc' | 'desc', offset: Number, limit: Number): IFTSArrayPromise

Sort and get all contents.

Public Constructors

public constructor(db: IndexedFTS, transaction: IDBTransaction) source

Params:

NameTypeAttributeDescription
db IndexedFTS

database.

transaction IDBTransaction

transaction of IndexedDB.

Public Members

public db: IndexedDB source

public promise: Promise<IndexedDB> source

Promise for await closing transaction.

public transaction: IDBTransaction source

Public Methods

public between(column: object, lower: object, upper: object): IFTSArrayPromise source

Get contents that have property is between argument values.

Params:

NameTypeAttributeDescription
column object

column name for search.

lower object

minimal value.

upper object

maximum value.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public delete(keys: object): Promise<IFTSTransaction> source

Delete contents from database.

Params:

NameTypeAttributeDescription
keys object

key of contents. allowed multiple arguments.

Return:

Promise<IFTSTransaction>

returns self for chain. Will reject with InvalidKeyError if keys included null or undefined.

public equals(column: object, value: object): IFTSArrayPromise source

Get contents that have fully matched property.

Params:

NameTypeAttributeDescription
column object

column name for search.

value object

value for search.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public filter(fun: function(content: object, index: Number): object): IFTSArrayPromise source

Filtering elements by function and returns IFTSArrayPromise.

WARNING: This method won't use the index. Other methods(eg. IFTSTransaction#equals or IFTSTransaction#lower may faster than this.

Params:

NameTypeAttributeDescription
fun function(content: object, index: Number): object

function for filtering element.

public get(key: object): Promise<object|undefined> source

Get content by primary key.

Params:

NameTypeAttributeDescription
key object

the key of content.

Return:

Promise<object|undefined>

content. promise will reject with InvalidKeyError if keys included null or undefined. result value will be undefined if not found.

public getAll(): IFTSArrayPromise source

Get all contents.

Return:

IFTSArrayPromise

contents.

public getNGrams(column: string, options: object): Promise<Map<string, number>> source

Get N-Gram set from index.

Params:

NameTypeAttributeDescription
column string

name of column.

options object
  • optional

optional arguments.

options.ignoreCase boolean
  • optional
  • default: false

ignore case when make result.

Return:

Promise<Map<string, number>>

public getWords(column: string, options: object): Promise<Map<string, number>> source

Get word set from index.

Params:

NameTypeAttributeDescription
column string

name of column.

options object
  • optional

optional arguments.

options.ignoreCase boolean
  • optional
  • default: false

ignore case when make result.

Return:

Promise<Map<string, number>>

public greater(column: object, value: object): IFTSArrayPromise source

Get contents that have property greater than value.

Params:

NameTypeAttributeDescription
column object

column name for search.

value object

value for search.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public greaterOrEquals(column: object, value: object): IFTSArrayPromise source

Get contents that have property greater than value or equals value.

Params:

NameTypeAttributeDescription
column object

column name for search.

value object

value for search.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public lower(column: object, value: object): IFTSArrayPromise source

Get contents that have property lower than value.

Params:

NameTypeAttributeDescription
column object

column name for search.

value object

value for search.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public lowerOrEquals(column: object, value: object): IFTSArrayPromise source

Get contents that have property lower than value or equals value.

Params:

NameTypeAttributeDescription
column object

column name for search.

value object

value for search.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public map(fun: function(content: object, index: Number): object): IFTSArrayPromise source

Do something process for each elements and returns IFTSArrayPromise.

NOTE: This method doesn't fast. May better do filtering before doing map if need filtering.

Params:

NameTypeAttributeDescription
fun function(content: object, index: Number): object

function for processing element.

public put(contents: object): Promise<IFTSTransaction> source

Put contents into database.

Params:

NameTypeAttributeDescription
contents object

contents for save. allowed multiple arguments.

Return:

Promise<IFTSTransaction>

returns self for chain.

Get contents that have matched property by full-text search.

All target columns have to made ngram index when created database. If you didn't made ngram index, you can use IFTSArrayPromise#search (but this way is very slow).

Params:

NameTypeAttributeDescription
columns object | object[]

column names for search.

query string

query for search.

options object
  • optional

optional arguments.

options.ignoreCase boolean
  • optional
  • default: false

ignore case if true. default is false.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public searchWord(columns: object | object[], query: string, options: object): IFTSArrayPromise source

Find contents that have fully matched word in property.

All target columns have to made word index when created database. If you didn't made word index, you can use IFTSArrayPromise#searchWord (but this way is very slow).

Params:

NameTypeAttributeDescription
columns object | object[]

column names for search.

query string

query for search.

options object
  • optional

optional arguments.

options.ignoreCase boolean
  • optional
  • default: false

ignore case if true. default is false.

Return:

IFTSArrayPromise

matched contents. may reject with NoSuchColumnError.

public sort(column: object, order: 'asc' | 'desc', offset: Number, limit: Number): IFTSArrayPromise source

Sort and get all contents.

Params:

NameTypeAttributeDescription
column object

the column for sorting.

order 'asc' | 'desc'
  • optional
  • default: 'asc'

sort order.

offset Number
  • optional
  • default: 0

starting offset of the result.

limit Number
  • optional

maximum number of result length. will unlimited if omitted.

Return:

IFTSArrayPromise

sorted contents.