IndexedFTS
The database of IndexedFTS.
Almost methods are the same interface as IDBTransaction and IFTSArrayPromise.
Static Method Summary
Static Public Methods | ||
public static |
Delete database. |
Constructor Summary
Public Constructor | ||
public |
constructor(name: string, version: number, schema: object | IFTSSchema, options: object) Create or open IndexedFTS. |
Member Summary
Public Members | ||
public |
db: IDBDatabase |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
|
Method Summary
Public Methods | ||
public |
between(column: object, lower: object, upper: object): IFTSArrayPromise Get contents that have property is between argument values. |
|
public |
close() Close database. |
|
public |
delete(keys: object): Promise<IndexedFTS> Delete contents from database. |
|
public |
equals(column: object, value: object): IFTSArrayPromise Get contents that have fully matched property. |
|
public |
Filtering elements by function and returns IFTSArrayPromise. |
|
public |
Get content by primary key. |
|
public |
Get all contents. |
|
public |
Get N-Gram set from index. |
|
public |
Get word set from index. |
|
public |
greater(column: object, value: object): IFTSArrayPromise Get contents that have property greater than value. |
|
public |
greaterOrEquals(column: object, value: object): IFTSArrayPromise 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 |
lowerOrEquals(column: object, value: object): IFTSArrayPromise Get contents that have property lower than value or equals value. |
|
public |
Do something process for each elements and returns IFTSArrayPromise. |
|
public |
Open database. |
|
public |
put(contents: object): Promise<IndexedFTS> Put contents into database. |
|
public |
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 |
transaction(mode: "readonly" | "readwrite", target: string[] | null): IFTSTransaction Make new IFTSTransaction. |
Static Public Methods
Public Constructors
public constructor(name: string, version: number, schema: object | IFTSSchema, options: object) source
Create or open IndexedFTS.
Database has name and schema's version. The name is a name of the database in the storage.
The schema is an object that key is column name and value is a definition of indexes. Schema can't change in same version database. If you want change schema of database, please change version number. Please be careful, all contents will remove when changing the version number.
Index types are 'primary', 'unique', 'fulltext', 'ngram', 'word', or 'normal'.
'primary' is a primary key of the database. 'primary' can't set to multiple columns. 'unique' is columns that have a unique value in the database. The 'normal' will enable when not primary and not unique. 'primary', 'unique' and 'normal' column can numeric search (eg. IndexedFTS#lower or IndexedFTS#between).
If set 'ngram' IndexedFTS will make 2-gram index table for full-text search. 'fulltext' is alias to 'ngram'.
'word' is word based index. The word index will split text with whitespaces and store those. Word index is faster than the 'ngram' index but can't find a partial match in the word.
If you want to set some index types, please use object like {unique: true, fulltext: true, normal: false}
.
Params:
Name | Type | Attribute | Description |
name | string | name of new (or open) database. |
|
version | number | schema's version of database. |
|
schema | object | IFTSSchema | database schema. |
|
options | object |
|
other options. |
options.index_prefix | string |
|
prefix of indexes for full-text search. |
options.scope | object |
|
endpoints for IndexedDB API. |
Throw:
Public Methods
public between(column: object, lower: object, upper: object): IFTSArrayPromise source
Get contents that have property is between argument values.
public delete(keys: object): Promise<IndexedFTS> source
Delete contents from database.
Params:
Name | Type | Attribute | Description |
keys | object | key of contents. |
Return:
Promise<IndexedFTS> | 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.
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. {@link IFTSTransaction#equals or @link IFTSTransaction#lower} may faster than this.
public get(key: object): Promise<object|undefined> source
Get content by primary key.
Params:
Name | Type | Attribute | Description |
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 getNGrams(column: string, options: object): Promise<Map<string, number>> source
Get N-Gram set from index.
public getWords(column: string, options: object): Promise<Map<string, number>> source
Get word set from index.
public greater(column: object, value: object): IFTSArrayPromise source
Get contents that have property greater than value.
public greaterOrEquals(column: object, value: object): IFTSArrayPromise source
Get contents that have property greater than value or equals value.
public lower(column: object, value: object): IFTSArrayPromise source
Get contents that have property lower than value.
public lowerOrEquals(column: object, value: object): IFTSArrayPromise source
Get contents that have property lower than value or equals value.
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.
public put(contents: object): Promise<IndexedFTS> source
Put contents into database.
Params:
Name | Type | Attribute | Description |
contents | object | contents for save. allowed multiple arguments. |
public search(columns: object | object[], query: string, options: object): IFTSArrayPromise source
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).
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).
public sort(column: object, order: 'asc' | 'desc', offset: Number, limit: Number): IFTSArrayPromise source
Sort and get all contents.
public transaction(mode: "readonly" | "readwrite", target: string[] | null): IFTSTransaction source
Make new IFTSTransaction.