Skip to content

Commit 35fd7c8

Browse files
committed
better support for result highlighting when using resolver
1 parent 1c4bcaa commit 35fd7c8

74 files changed

Lines changed: 4857 additions & 5042 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ Global Members:
910910
##
911911

912912
- <small>_async_</small> index.[**mount**](doc/persistent.md)(db)
913-
- <small>_async_</small> index.[**commit**](doc/persistent.md)(boolean)
913+
- <small>_async_</small> index.[**commit**](doc/persistent.md)()
914914
- <small>_async_</small> index.[**destroy**](doc/persistent.md#delete-store--migration)()
915915

916916
---
@@ -939,7 +939,7 @@ Global Members:
939939
##
940940

941941
- <small>_async_</small> document.[**mount**](doc/persistent.md)(db)
942-
- <small>_async_</small> document.[**commit**](doc/persistent.md)(boolean)
942+
- <small>_async_</small> document.[**commit**](doc/persistent.md)()
943943
- <small>_async_</small> document.[**destroy**](doc/persistent.md#delete-store--migration)()
944944

945945
`Document` Properties:
@@ -955,6 +955,7 @@ Async Equivalents (Non-Blocking Balanced):
955955
- <small>_async_</small> [**.updateAsync**](doc/async.md)( ... , \<callback\>)
956956
- <small>_async_</small> [**.removeAsync**](doc/async.md)( ... , \<callback\>)
957957
- <small>_async_</small> [**.searchAsync**](doc/async.md)( ... , \<callback\>)
958+
- <small>_async_</small> [**.searchCacheAsync**](doc/async.md)( ... , \<callback\>)
958959

959960
Async methods will return a `Promise`, additionally you can pass a callback function as the last parameter.
960961

@@ -988,6 +989,7 @@ Methods `.export()` and also `.import()` are always async as well as every metho
988989
`Resolver` Properties:
989990

990991
- resolver.[**result**](doc/resolver.md)
992+
- resolver.[**await**](doc/resolver.md) (Async)
991993

992994
---
993995

@@ -998,6 +1000,7 @@ Methods `.export()` and also `.import()` are always async as well as every metho
9981000
- <small>_async_</small> db.[**close**](doc/persistent.md)()
9991001
- <small>_async_</small> db.[**destroy**](doc/persistent.md)()
10001002
- <small>_async_</small> db.[**clear**](doc/persistent.md)()
1003+
- <small>_async_</small> db.[**commit**](doc/persistent.md)(index)
10011004

10021005
---
10031006

dist/db/clickhouse/index.cjs

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -519,36 +519,25 @@ ClickhouseDB.prototype.transaction = function(task){
519519
return task.call(this);
520520
};
521521

522-
ClickhouseDB.prototype.commit = async function(flexsearch, _replace, _append){
522+
ClickhouseDB.prototype.commit = async function(flexsearch){
523523

524-
525-
if(_replace){
526-
await this.clear();
527-
528-
flexsearch.commit_task = [];
529-
}
530-
else {
531-
let tasks = flexsearch.commit_task;
532-
flexsearch.commit_task = [];
533-
for(let i = 0, task; i < tasks.length; i++){
534-
task = tasks[i];
535-
536-
if(task.clear){
537-
await this.clear();
538-
_replace = true;
539-
break;
540-
}
541-
else {
542-
tasks[i] = task.del;
543-
}
544-
}
545-
if(!_replace){
546-
if(!_append){
547-
tasks = tasks.concat(toArray(flexsearch.reg));
548-
}
549-
tasks.length && await this.remove(tasks);
524+
let tasks = flexsearch.commit_task;
525+
let removals = [];
526+
flexsearch.commit_task = [];
527+
528+
for(let i = 0, task; i < tasks.length; i++){
529+
/** @dict */
530+
task = tasks[i];
531+
if(task["del"]){
532+
removals.push(task["del"]);
550533
}
534+
else if(task["ins"]);
551535
}
536+
537+
if(removals.length){
538+
await this.remove(removals);
539+
}
540+
552541
if(!flexsearch.reg.size){
553542
return;
554543
}

dist/db/indexeddb/index.cjs

Lines changed: 24 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,6 @@
99

1010
function create_object(){
1111
return Object.create(null);
12-
}
13-
14-
/**
15-
* @param {Map|Set} val
16-
* @param {boolean=} stringify
17-
* @return {Array}
18-
*/
19-
20-
function toArray(val, stringify){
21-
const result = [];
22-
for(const key of val.keys()){
23-
result.push(key);
24-
}
25-
return result;
2612
}
2713

2814
const VERSION = 1;
@@ -363,36 +349,25 @@ IdxDB.prototype.transaction = function(ref, modifier, task){
363349

364350
};
365351

366-
IdxDB.prototype.commit = async function(flexsearch, _replace, _append){
352+
IdxDB.prototype.commit = async function(flexsearch){
367353

368-
369-
if(_replace){
370-
await this.clear();
354+
let tasks = flexsearch.commit_task;
355+
let removals = [];
356+
flexsearch.commit_task = [];
357+
358+
for(let i = 0, task; i < tasks.length; i++){
359+
/** @dict */
360+
task = tasks[i];
361+
if(task["del"]){
362+
removals.push(task["del"]);
363+
}
364+
365+
371366

372-
flexsearch.commit_task = [];
373367
}
374-
else {
375-
let tasks = flexsearch.commit_task;
376-
flexsearch.commit_task = [];
377-
for(let i = 0, task; i < tasks.length; i++){
378-
/** @dict */
379-
task = tasks[i];
380-
381-
if(task["clear"]){
382-
await this.clear();
383-
_replace = true;
384-
break;
385-
}
386-
else {
387-
tasks[i] = task["del"];
388-
}
389-
}
390-
if(!_replace){
391-
if(!_append){
392-
tasks = tasks.concat(toArray(flexsearch.reg));
393-
}
394-
tasks.length && await this.remove(tasks);
395-
}
368+
369+
if(removals.length){
370+
await this.remove(removals);
396371
}
397372

398373
if(!flexsearch.reg.size){
@@ -407,10 +382,10 @@ IdxDB.prototype.commit = async function(flexsearch, _replace, _append){
407382
const value = item[1];
408383
if(!value.length) continue;
409384

410-
if(_replace){
411-
store.put(value, key);
412-
continue;
413-
}
385+
386+
387+
388+
414389

415390
store.get(key).onsuccess = function(){
416391
let result = this.result;
@@ -464,10 +439,10 @@ IdxDB.prototype.commit = async function(flexsearch, _replace, _append){
464439
const value = item[1];
465440
if(!value.length) continue;
466441

467-
if(_replace){
468-
store.put(value, ctx_key + ":" + key);
469-
continue;
470-
}
442+
443+
444+
445+
471446

472447
store.get(ctx_key + ":" + key).onsuccess = function(){
473448
let result = this.result;

dist/db/mongodb/index.cjs

Lines changed: 15 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,6 @@
22

33
var mongodb = require('mongodb');
44

5-
/**
6-
* @param {*} value
7-
* @param {*} default_value
8-
* @param {*=} merge_value
9-
* @return {*}
10-
*/
11-
12-
/**
13-
* @param {Map|Set} val
14-
* @param {boolean=} stringify
15-
* @return {Array}
16-
*/
17-
18-
function toArray(val, stringify){
19-
const result = [];
20-
for(const key of val.keys()){
21-
result.push(key);
22-
}
23-
return result;
24-
}
25-
265
const defaults = {
276
host: "localhost",
287
port: "27017",
@@ -565,35 +544,23 @@ MongoDB.prototype.transaction = function(task){
565544
return task.call(this);
566545
};
567546

568-
MongoDB.prototype.commit = async function(flexsearch, _replace, _append){
547+
MongoDB.prototype.commit = async function(flexsearch){
569548

570-
571-
if(_replace){
572-
await this.clear();
573-
574-
flexsearch.commit_task = [];
575-
}
576-
else {
577-
let tasks = flexsearch.commit_task;
578-
flexsearch.commit_task = [];
579-
for(let i = 0, task; i < tasks.length; i++){
580-
task = tasks[i];
581-
582-
if(task.clear){
583-
await this.clear();
584-
_replace = true;
585-
break;
586-
}
587-
else {
588-
tasks[i] = task.del;
589-
}
590-
}
591-
if(!_replace){
592-
if(!_append){
593-
tasks = tasks.concat(toArray(flexsearch.reg));
594-
}
595-
tasks.length && await this.remove(tasks);
549+
let tasks = flexsearch.commit_task;
550+
let removals = [];
551+
flexsearch.commit_task = [];
552+
553+
for(let i = 0, task; i < tasks.length; i++){
554+
/** @dict */
555+
task = tasks[i];
556+
if(task["del"]){
557+
removals.push(task["del"]);
596558
}
559+
else if(task["ins"]);
560+
}
561+
562+
if(removals.length){
563+
await this.remove(removals);
597564
}
598565

599566
if(!flexsearch.reg.size){

dist/db/postgres/index.cjs

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@ var pg_promise = require('pg-promise');
1111

1212
function concat(arrays){
1313
return [].concat.apply([], arrays);
14-
}
15-
16-
/**
17-
* @param {Map|Set} val
18-
* @param {boolean=} stringify
19-
* @return {Array}
20-
*/
21-
22-
function toArray(val, stringify){
23-
const result = [];
24-
for(const key of val.keys()){
25-
result.push(key);
26-
}
27-
return result;
2814
}
2915

3016
const defaults = {
@@ -565,37 +551,23 @@ PostgresDB.prototype.transaction = function(task){
565551
};
566552

567553

568-
PostgresDB.prototype.commit = async function(flexsearch, _replace, _append){
554+
PostgresDB.prototype.commit = async function(flexsearch){
569555

570-
571-
if(_replace){
572-
await this.clear();
573-
574-
flexsearch.commit_task = [];
575-
}
576-
else {
577-
let tasks = flexsearch.commit_task;
578-
flexsearch.commit_task = [];
579-
for(let i = 0, task; i < tasks.length; i++){
580-
task = tasks[i];
581-
582-
if(task.clear){
583-
await this.clear();
584-
_replace = true;
585-
break;
586-
}
587-
else {
588-
tasks[i] = task.del;
589-
}
590-
}
591-
if(!_replace){
592-
if(!_append){
593-
tasks = tasks.concat(toArray(flexsearch.reg));
594-
}
595-
tasks.length && await this.remove(tasks);
556+
let tasks = flexsearch.commit_task;
557+
let removals = [];
558+
flexsearch.commit_task = [];
559+
560+
for(let i = 0, task; i < tasks.length; i++){
561+
/** @dict */
562+
task = tasks[i];
563+
if(task["del"]){
564+
removals.push(task["del"]);
596565
}
566+
else if(task["ins"]);
567+
}
597568

598-
569+
if(removals.length){
570+
await this.remove(removals);
599571
}
600572

601573
if(!flexsearch.reg.size){

0 commit comments

Comments
 (0)