@peerbit/indexer-tests 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/benchmarks.d.ts +1 -1
- package/dist/src/benchmarks.d.ts.map +1 -1
- package/dist/src/benchmarks.js +119 -18
- package/dist/src/benchmarks.js.map +1 -1
- package/dist/src/tests.d.ts.map +1 -1
- package/dist/src/tests.js +445 -391
- package/dist/src/tests.js.map +1 -1
- package/package.json +2 -2
- package/src/benchmarks.ts +141 -29
- package/src/tests.ts +918 -1102
package/src/tests.ts
CHANGED
|
@@ -13,28 +13,25 @@ import {
|
|
|
13
13
|
BoolQuery,
|
|
14
14
|
ByteMatchQuery,
|
|
15
15
|
Compare,
|
|
16
|
-
CountRequest,
|
|
17
|
-
DeleteRequest,
|
|
18
16
|
type Index,
|
|
19
17
|
type IndexEngineInitProperties,
|
|
18
|
+
type IndexIterator,
|
|
20
19
|
type Indices,
|
|
21
20
|
IntegerCompare,
|
|
22
21
|
IsNull,
|
|
22
|
+
type IterateOptions,
|
|
23
23
|
Nested,
|
|
24
24
|
Not,
|
|
25
25
|
Or,
|
|
26
26
|
Query,
|
|
27
|
-
SearchRequest,
|
|
28
27
|
type Shape,
|
|
29
28
|
Sort,
|
|
30
29
|
SortDirection,
|
|
31
30
|
StringMatch,
|
|
32
31
|
StringMatchMethod,
|
|
33
|
-
SumRequest,
|
|
34
32
|
extractFieldValue,
|
|
35
33
|
getIdProperty,
|
|
36
34
|
id,
|
|
37
|
-
iterate,
|
|
38
35
|
toId,
|
|
39
36
|
} from "@peerbit/indexer-interface";
|
|
40
37
|
import {
|
|
@@ -125,14 +122,21 @@ class DocumentNext extends Base {
|
|
|
125
122
|
const bigIntSort = <T extends number | bigint>(a: T, b: T): number =>
|
|
126
123
|
a > b ? 1 : 0 || -(a < b);
|
|
127
124
|
|
|
128
|
-
const search = <T>(
|
|
125
|
+
const search = <T, S extends Shape | undefined>(
|
|
129
126
|
index: Index<T, any>,
|
|
130
|
-
query:
|
|
131
|
-
options?: { shape:
|
|
127
|
+
query: IterateOptions,
|
|
128
|
+
options?: { shape: S },
|
|
132
129
|
) => {
|
|
133
130
|
// fetch max u32
|
|
134
|
-
query.
|
|
135
|
-
|
|
131
|
+
return index.iterate<S>(query, options).all();
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const assertIteratorIsDone = async (iterator: IndexIterator<any, any>) => {
|
|
135
|
+
const next = await iterator.next(1);
|
|
136
|
+
if (next.length > 0) {
|
|
137
|
+
throw new Error(`Iterator is not done, got more results`);
|
|
138
|
+
}
|
|
139
|
+
expect(iterator.done()).to.be.true;
|
|
136
140
|
};
|
|
137
141
|
|
|
138
142
|
export const tests = (
|
|
@@ -307,11 +311,9 @@ export const tests = (
|
|
|
307
311
|
}
|
|
308
312
|
}
|
|
309
313
|
|
|
310
|
-
await store.del(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}),
|
|
314
|
-
);
|
|
314
|
+
await store.del({
|
|
315
|
+
query: deleteQueryObject,
|
|
316
|
+
});
|
|
315
317
|
expect(await store.getSize()).equal(0);
|
|
316
318
|
result = await store.get(toId(docId));
|
|
317
319
|
|
|
@@ -396,20 +398,17 @@ export const tests = (
|
|
|
396
398
|
|
|
397
399
|
await store.put(doc);
|
|
398
400
|
|
|
399
|
-
const results = await search(
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
}),
|
|
411
|
-
);
|
|
412
|
-
expect(results.results).to.have.length(1);
|
|
401
|
+
const results = await search(store, {
|
|
402
|
+
query: [
|
|
403
|
+
new StringMatch({
|
|
404
|
+
key: "id",
|
|
405
|
+
value: "123",
|
|
406
|
+
caseInsensitive: false,
|
|
407
|
+
method: StringMatchMethod.contains,
|
|
408
|
+
}),
|
|
409
|
+
],
|
|
410
|
+
});
|
|
411
|
+
expect(results).to.have.length(1);
|
|
413
412
|
});
|
|
414
413
|
});
|
|
415
414
|
|
|
@@ -569,9 +568,9 @@ export const tests = (
|
|
|
569
568
|
it("no-args", async () => {
|
|
570
569
|
await setupDefault();
|
|
571
570
|
|
|
572
|
-
const results = await search(store,
|
|
573
|
-
expect(results
|
|
574
|
-
for (const result of results
|
|
571
|
+
const results = await search(store, { query: [] });
|
|
572
|
+
expect(results).to.have.length(4);
|
|
573
|
+
for (const result of results) {
|
|
575
574
|
checkDocument(result.value, ...defaultDocs);
|
|
576
575
|
}
|
|
577
576
|
});
|
|
@@ -581,136 +580,115 @@ export const tests = (
|
|
|
581
580
|
await setupDefault();
|
|
582
581
|
});
|
|
583
582
|
it("exact", async () => {
|
|
584
|
-
const responses = await search(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
responses.results.map((x) => x.id.primitive),
|
|
598
|
-
).to.have.members(["1", "2"]);
|
|
583
|
+
const responses = await search(store, {
|
|
584
|
+
query: [
|
|
585
|
+
new StringMatch({
|
|
586
|
+
key: "name",
|
|
587
|
+
value: "hello world",
|
|
588
|
+
caseInsensitive: true,
|
|
589
|
+
}),
|
|
590
|
+
],
|
|
591
|
+
});
|
|
592
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
593
|
+
"1",
|
|
594
|
+
"2",
|
|
595
|
+
]);
|
|
599
596
|
});
|
|
600
597
|
|
|
601
598
|
it("exact-case-insensitive", async () => {
|
|
602
|
-
const responses = await search(
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
responses.results.map((x) => x.id.primitive),
|
|
617
|
-
).to.have.members(["1", "2"]);
|
|
599
|
+
const responses = await search(store, {
|
|
600
|
+
query: [
|
|
601
|
+
new StringMatch({
|
|
602
|
+
key: "name",
|
|
603
|
+
value: "Hello World",
|
|
604
|
+
caseInsensitive: true,
|
|
605
|
+
}),
|
|
606
|
+
],
|
|
607
|
+
});
|
|
608
|
+
expect(responses).to.have.length(2);
|
|
609
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
610
|
+
"1",
|
|
611
|
+
"2",
|
|
612
|
+
]);
|
|
618
613
|
});
|
|
619
614
|
|
|
620
615
|
it("exact case sensitive", async () => {
|
|
621
|
-
let responses = await search(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
key: "name",
|
|
643
|
-
value: "hello world",
|
|
644
|
-
caseInsensitive: false,
|
|
645
|
-
}),
|
|
646
|
-
],
|
|
647
|
-
}),
|
|
648
|
-
);
|
|
649
|
-
expect(
|
|
650
|
-
responses.results.map((x) => x.id.primitive),
|
|
651
|
-
).to.have.members(["1"]);
|
|
616
|
+
let responses = await search(store, {
|
|
617
|
+
query: [
|
|
618
|
+
new StringMatch({
|
|
619
|
+
key: "name",
|
|
620
|
+
value: "Hello World",
|
|
621
|
+
caseInsensitive: false,
|
|
622
|
+
}),
|
|
623
|
+
],
|
|
624
|
+
});
|
|
625
|
+
expect(responses).to.have.length(1);
|
|
626
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members(["2"]);
|
|
627
|
+
responses = await search(store, {
|
|
628
|
+
query: [
|
|
629
|
+
new StringMatch({
|
|
630
|
+
key: "name",
|
|
631
|
+
value: "hello world",
|
|
632
|
+
caseInsensitive: false,
|
|
633
|
+
}),
|
|
634
|
+
],
|
|
635
|
+
});
|
|
636
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members(["1"]);
|
|
652
637
|
});
|
|
653
638
|
it("prefix", async () => {
|
|
654
|
-
const responses = await search(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
responses.results.map((x) => x.id.primitive),
|
|
670
|
-
).to.have.members(["1", "2"]);
|
|
639
|
+
const responses = await search(store, {
|
|
640
|
+
query: [
|
|
641
|
+
new StringMatch({
|
|
642
|
+
key: "name",
|
|
643
|
+
value: "hel",
|
|
644
|
+
method: StringMatchMethod.prefix,
|
|
645
|
+
caseInsensitive: true,
|
|
646
|
+
}),
|
|
647
|
+
],
|
|
648
|
+
});
|
|
649
|
+
expect(responses).to.have.length(2);
|
|
650
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
651
|
+
"1",
|
|
652
|
+
"2",
|
|
653
|
+
]);
|
|
671
654
|
});
|
|
672
655
|
|
|
673
656
|
it("contains", async () => {
|
|
674
|
-
const responses = await search(
|
|
675
|
-
|
|
676
|
-
|
|
657
|
+
const responses = await search(store, {
|
|
658
|
+
query: [
|
|
659
|
+
new StringMatch({
|
|
660
|
+
key: "name",
|
|
661
|
+
value: "ello",
|
|
662
|
+
method: StringMatchMethod.contains,
|
|
663
|
+
caseInsensitive: true,
|
|
664
|
+
}),
|
|
665
|
+
],
|
|
666
|
+
});
|
|
667
|
+
expect(responses).to.have.length(2);
|
|
668
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
669
|
+
"1",
|
|
670
|
+
"2",
|
|
671
|
+
]);
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
describe("arr", () => {
|
|
675
|
+
it("arr", async () => {
|
|
676
|
+
const responses = await search(store, {
|
|
677
677
|
query: [
|
|
678
678
|
new StringMatch({
|
|
679
|
-
key: "
|
|
680
|
-
value: "
|
|
679
|
+
key: "tags",
|
|
680
|
+
value: "world",
|
|
681
681
|
method: StringMatchMethod.contains,
|
|
682
682
|
caseInsensitive: true,
|
|
683
683
|
}),
|
|
684
684
|
],
|
|
685
|
-
})
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
).to.have.members(["1", "2"]);
|
|
691
|
-
});
|
|
692
|
-
|
|
693
|
-
describe("arr", () => {
|
|
694
|
-
it("arr", async () => {
|
|
695
|
-
const responses = await search(
|
|
696
|
-
store,
|
|
697
|
-
new SearchRequest({
|
|
698
|
-
query: [
|
|
699
|
-
new StringMatch({
|
|
700
|
-
key: "tags",
|
|
701
|
-
value: "world",
|
|
702
|
-
method: StringMatchMethod.contains,
|
|
703
|
-
caseInsensitive: true,
|
|
704
|
-
}),
|
|
705
|
-
],
|
|
706
|
-
}),
|
|
707
|
-
);
|
|
708
|
-
expect(responses.results).to.have.length(1);
|
|
709
|
-
expect(
|
|
710
|
-
responses.results.map((x) => x.id.primitive),
|
|
711
|
-
).to.have.members(["2"]);
|
|
685
|
+
});
|
|
686
|
+
expect(responses).to.have.length(1);
|
|
687
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
688
|
+
"2",
|
|
689
|
+
]);
|
|
712
690
|
|
|
713
|
-
checkDocument(responses
|
|
691
|
+
checkDocument(responses[0].value, ...defaultDocs);
|
|
714
692
|
});
|
|
715
693
|
});
|
|
716
694
|
});
|
|
@@ -718,21 +696,16 @@ export const tests = (
|
|
|
718
696
|
it("missing", async () => {
|
|
719
697
|
await setupDefault();
|
|
720
698
|
|
|
721
|
-
const responses = await search(
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
],
|
|
729
|
-
}),
|
|
730
|
-
);
|
|
699
|
+
const responses = await search(store, {
|
|
700
|
+
query: [
|
|
701
|
+
new IsNull({
|
|
702
|
+
key: "name",
|
|
703
|
+
}),
|
|
704
|
+
],
|
|
705
|
+
});
|
|
731
706
|
|
|
732
|
-
expect(responses
|
|
733
|
-
expect(responses.
|
|
734
|
-
"4",
|
|
735
|
-
]);
|
|
707
|
+
expect(responses).to.have.length(1);
|
|
708
|
+
expect(responses.map((x) => x.id.primitive)).to.deep.equal(["4"]);
|
|
736
709
|
});
|
|
737
710
|
|
|
738
711
|
describe("uint8arrays", () => {
|
|
@@ -741,77 +714,65 @@ export const tests = (
|
|
|
741
714
|
it("matches", async () => {
|
|
742
715
|
await setupDefault();
|
|
743
716
|
|
|
744
|
-
const responses = await search(
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
new
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
expect(
|
|
757
|
-
responses.results.map((x) => x.id.primitive),
|
|
758
|
-
).to.deep.equal(["1"]);
|
|
717
|
+
const responses = await search(store, {
|
|
718
|
+
query: [
|
|
719
|
+
new ByteMatchQuery({
|
|
720
|
+
key: "data",
|
|
721
|
+
value: new Uint8Array([1]),
|
|
722
|
+
}),
|
|
723
|
+
],
|
|
724
|
+
});
|
|
725
|
+
expect(responses).to.have.length(1);
|
|
726
|
+
expect(responses.map((x) => x.id.primitive)).to.deep.equal([
|
|
727
|
+
"1",
|
|
728
|
+
]);
|
|
759
729
|
});
|
|
760
730
|
it("un-matches", async () => {
|
|
761
731
|
await setupDefault();
|
|
762
732
|
|
|
763
|
-
const responses = await search(
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
new
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}),
|
|
773
|
-
);
|
|
774
|
-
expect(responses.results).to.be.empty;
|
|
733
|
+
const responses = await search(store, {
|
|
734
|
+
query: [
|
|
735
|
+
new ByteMatchQuery({
|
|
736
|
+
key: "data",
|
|
737
|
+
value: new Uint8Array([199]),
|
|
738
|
+
}),
|
|
739
|
+
],
|
|
740
|
+
});
|
|
741
|
+
expect(responses).to.be.empty;
|
|
775
742
|
});
|
|
776
743
|
});
|
|
777
744
|
describe("integer", () => {
|
|
778
745
|
it("exists", async () => {
|
|
779
746
|
await setupDefault();
|
|
780
747
|
|
|
781
|
-
const responses = await search(
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
expect(
|
|
795
|
-
responses.results.map((x) => x.id.primitive),
|
|
796
|
-
).to.deep.equal(["1"]);
|
|
748
|
+
const responses = await search(store, {
|
|
749
|
+
query: [
|
|
750
|
+
new IntegerCompare({
|
|
751
|
+
key: "data",
|
|
752
|
+
compare: Compare.Equal,
|
|
753
|
+
value: 1,
|
|
754
|
+
}),
|
|
755
|
+
],
|
|
756
|
+
});
|
|
757
|
+
expect(responses).to.have.length(1);
|
|
758
|
+
expect(responses.map((x) => x.id.primitive)).to.deep.equal([
|
|
759
|
+
"1",
|
|
760
|
+
]);
|
|
797
761
|
});
|
|
798
762
|
|
|
799
763
|
it("does not exist", async () => {
|
|
800
764
|
await setupDefault();
|
|
801
765
|
|
|
802
|
-
const responses = await search(
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
}),
|
|
813
|
-
);
|
|
814
|
-
expect(responses.results).to.be.empty;
|
|
766
|
+
const responses = await search(store, {
|
|
767
|
+
query: [
|
|
768
|
+
new IntegerCompare({
|
|
769
|
+
key: "data",
|
|
770
|
+
compare: Compare.Equal,
|
|
771
|
+
value: 199,
|
|
772
|
+
}),
|
|
773
|
+
],
|
|
774
|
+
});
|
|
775
|
+
expect(responses).to.be.empty;
|
|
815
776
|
});
|
|
816
777
|
});
|
|
817
778
|
});
|
|
@@ -821,77 +782,65 @@ export const tests = (
|
|
|
821
782
|
it("matches", async () => {
|
|
822
783
|
await setupDefault();
|
|
823
784
|
|
|
824
|
-
const responses = await search(
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
new
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
expect(
|
|
837
|
-
responses.results.map((x) => x.id.primitive),
|
|
838
|
-
).to.deep.equal(["1"]);
|
|
785
|
+
const responses = await search(store, {
|
|
786
|
+
query: [
|
|
787
|
+
new ByteMatchQuery({
|
|
788
|
+
key: "fixedData",
|
|
789
|
+
value: new Uint8Array(32).fill(1),
|
|
790
|
+
}),
|
|
791
|
+
],
|
|
792
|
+
});
|
|
793
|
+
expect(responses).to.have.length(1);
|
|
794
|
+
expect(responses.map((x) => x.id.primitive)).to.deep.equal([
|
|
795
|
+
"1",
|
|
796
|
+
]);
|
|
839
797
|
});
|
|
840
798
|
it("un-matches", async () => {
|
|
841
799
|
await setupDefault();
|
|
842
800
|
|
|
843
|
-
const responses = await search(
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
new
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
}),
|
|
853
|
-
);
|
|
854
|
-
expect(responses.results).to.be.empty;
|
|
801
|
+
const responses = await search(store, {
|
|
802
|
+
query: [
|
|
803
|
+
new ByteMatchQuery({
|
|
804
|
+
key: "data",
|
|
805
|
+
value: new Uint8Array(32).fill(99),
|
|
806
|
+
}),
|
|
807
|
+
],
|
|
808
|
+
});
|
|
809
|
+
expect(responses).to.be.empty;
|
|
855
810
|
});
|
|
856
811
|
});
|
|
857
812
|
describe("integer", () => {
|
|
858
813
|
it("exists", async () => {
|
|
859
814
|
await setupDefault();
|
|
860
815
|
|
|
861
|
-
const responses = await search(
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
expect(
|
|
875
|
-
responses.results.map((x) => x.id.primitive),
|
|
876
|
-
).to.deep.equal(["1"]);
|
|
816
|
+
const responses = await search(store, {
|
|
817
|
+
query: [
|
|
818
|
+
new IntegerCompare({
|
|
819
|
+
key: "data",
|
|
820
|
+
compare: Compare.Equal,
|
|
821
|
+
value: 1,
|
|
822
|
+
}),
|
|
823
|
+
],
|
|
824
|
+
});
|
|
825
|
+
expect(responses).to.have.length(1);
|
|
826
|
+
expect(responses.map((x) => x.id.primitive)).to.deep.equal([
|
|
827
|
+
"1",
|
|
828
|
+
]);
|
|
877
829
|
});
|
|
878
830
|
|
|
879
831
|
it("does not exist", async () => {
|
|
880
832
|
await setupDefault();
|
|
881
833
|
|
|
882
|
-
const responses = await search(
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
}),
|
|
893
|
-
);
|
|
894
|
-
expect(responses.results).to.be.empty;
|
|
834
|
+
const responses = await search(store, {
|
|
835
|
+
query: [
|
|
836
|
+
new IntegerCompare({
|
|
837
|
+
key: "data",
|
|
838
|
+
compare: Compare.Equal,
|
|
839
|
+
value: 199,
|
|
840
|
+
}),
|
|
841
|
+
],
|
|
842
|
+
});
|
|
843
|
+
expect(responses).to.be.empty;
|
|
895
844
|
});
|
|
896
845
|
});
|
|
897
846
|
});
|
|
@@ -899,21 +848,16 @@ export const tests = (
|
|
|
899
848
|
+it("bool", async () => {
|
|
900
849
|
await setupDefault();
|
|
901
850
|
|
|
902
|
-
const responses = await search(
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
);
|
|
913
|
-
expect(responses.results).to.have.length(1);
|
|
914
|
-
expect(responses.results.map((x) => x.id.primitive)).to.deep.equal([
|
|
915
|
-
"1",
|
|
916
|
-
]);
|
|
851
|
+
const responses = await search(store, {
|
|
852
|
+
query: [
|
|
853
|
+
new BoolQuery({
|
|
854
|
+
key: "bool",
|
|
855
|
+
value: true,
|
|
856
|
+
}),
|
|
857
|
+
],
|
|
858
|
+
});
|
|
859
|
+
expect(responses).to.have.length(1);
|
|
860
|
+
expect(responses.map((x) => x.id.primitive)).to.deep.equal(["1"]);
|
|
917
861
|
});
|
|
918
862
|
|
|
919
863
|
describe("array", () => {
|
|
@@ -944,20 +888,15 @@ export const tests = (
|
|
|
944
888
|
}),
|
|
945
889
|
);
|
|
946
890
|
|
|
947
|
-
const results = await search(
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
new
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
}),
|
|
957
|
-
);
|
|
958
|
-
expect(results.results.map((x) => x.value.id)).to.deep.equal([
|
|
959
|
-
d1.id,
|
|
960
|
-
]);
|
|
891
|
+
const results = await search(store, {
|
|
892
|
+
query: [
|
|
893
|
+
new ByteMatchQuery({
|
|
894
|
+
key: "bytesArrays",
|
|
895
|
+
value: new Uint8Array([2]),
|
|
896
|
+
}),
|
|
897
|
+
],
|
|
898
|
+
});
|
|
899
|
+
expect(results.map((x) => x.value.id)).to.deep.equal([d1.id]);
|
|
961
900
|
});
|
|
962
901
|
});
|
|
963
902
|
|
|
@@ -993,19 +932,14 @@ export const tests = (
|
|
|
993
932
|
}),
|
|
994
933
|
);
|
|
995
934
|
|
|
996
|
-
const results = await search(
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
compare: Compare.Equal,
|
|
1002
|
-
value: d1.documents[0]!.number,
|
|
1003
|
-
}),
|
|
935
|
+
const results = await search(store, {
|
|
936
|
+
query: new IntegerCompare({
|
|
937
|
+
key: ["documents", "number"],
|
|
938
|
+
compare: Compare.Equal,
|
|
939
|
+
value: d1.documents[0]!.number,
|
|
1004
940
|
}),
|
|
1005
|
-
);
|
|
1006
|
-
expect(results.
|
|
1007
|
-
d1.id,
|
|
1008
|
-
]);
|
|
941
|
+
});
|
|
942
|
+
expect(results.map((x) => x.value.id)).to.deep.equal([d1.id]);
|
|
1009
943
|
});
|
|
1010
944
|
|
|
1011
945
|
it("update array", async () => {
|
|
@@ -1028,32 +962,26 @@ export const tests = (
|
|
|
1028
962
|
// should have update results
|
|
1029
963
|
expect(
|
|
1030
964
|
(
|
|
1031
|
-
await search(
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
compare: Compare.Equal,
|
|
1037
|
-
value: 123n,
|
|
1038
|
-
}),
|
|
965
|
+
await search(store, {
|
|
966
|
+
query: new IntegerCompare({
|
|
967
|
+
key: ["documents", "number"],
|
|
968
|
+
compare: Compare.Equal,
|
|
969
|
+
value: 123n,
|
|
1039
970
|
}),
|
|
1040
|
-
)
|
|
1041
|
-
).
|
|
971
|
+
})
|
|
972
|
+
).length,
|
|
1042
973
|
).to.equal(0);
|
|
1043
974
|
|
|
1044
975
|
expect(
|
|
1045
976
|
(
|
|
1046
|
-
await search(
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
compare: Compare.Equal,
|
|
1052
|
-
value: 124n,
|
|
1053
|
-
}),
|
|
977
|
+
await search(store, {
|
|
978
|
+
query: new IntegerCompare({
|
|
979
|
+
key: ["documents", "number"],
|
|
980
|
+
compare: Compare.Equal,
|
|
981
|
+
value: 124n,
|
|
1054
982
|
}),
|
|
1055
|
-
)
|
|
1056
|
-
).
|
|
983
|
+
})
|
|
984
|
+
).map((x) => x.value.id),
|
|
1057
985
|
).to.deep.equal([d1.id]);
|
|
1058
986
|
});
|
|
1059
987
|
|
|
@@ -1067,29 +995,24 @@ export const tests = (
|
|
|
1067
995
|
});
|
|
1068
996
|
|
|
1069
997
|
await store.put(d1);
|
|
1070
|
-
const [deleted] = await store.del(
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
}),
|
|
1076
|
-
);
|
|
998
|
+
const [deleted] = await store.del({
|
|
999
|
+
query: {
|
|
1000
|
+
id: d1.id,
|
|
1001
|
+
},
|
|
1002
|
+
});
|
|
1077
1003
|
|
|
1078
1004
|
expect(deleted.key).to.deep.equal(d1.id);
|
|
1079
1005
|
|
|
1080
1006
|
expect(
|
|
1081
1007
|
(
|
|
1082
|
-
await search(
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
compare: Compare.Equal,
|
|
1088
|
-
value: 123n,
|
|
1089
|
-
}),
|
|
1008
|
+
await search(store, {
|
|
1009
|
+
query: new IntegerCompare({
|
|
1010
|
+
key: ["documents", "number"],
|
|
1011
|
+
compare: Compare.Equal,
|
|
1012
|
+
value: 123n,
|
|
1090
1013
|
}),
|
|
1091
|
-
)
|
|
1092
|
-
).
|
|
1014
|
+
})
|
|
1015
|
+
).length,
|
|
1093
1016
|
).to.equal(0);
|
|
1094
1017
|
|
|
1095
1018
|
d1.documents = [
|
|
@@ -1099,32 +1022,26 @@ export const tests = (
|
|
|
1099
1022
|
|
|
1100
1023
|
expect(
|
|
1101
1024
|
(
|
|
1102
|
-
await search(
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
compare: Compare.Equal,
|
|
1108
|
-
value: 124n,
|
|
1109
|
-
}),
|
|
1025
|
+
await search(store, {
|
|
1026
|
+
query: new IntegerCompare({
|
|
1027
|
+
key: ["documents", "number"],
|
|
1028
|
+
compare: Compare.Equal,
|
|
1029
|
+
value: 124n,
|
|
1110
1030
|
}),
|
|
1111
|
-
)
|
|
1112
|
-
).
|
|
1031
|
+
})
|
|
1032
|
+
).map((x) => x.value.id),
|
|
1113
1033
|
).to.deep.equal([d1.id]);
|
|
1114
1034
|
|
|
1115
1035
|
expect(
|
|
1116
1036
|
(
|
|
1117
|
-
await search(
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
compare: Compare.Equal,
|
|
1123
|
-
value: 123n,
|
|
1124
|
-
}),
|
|
1037
|
+
await search(store, {
|
|
1038
|
+
query: new IntegerCompare({
|
|
1039
|
+
key: ["documents", "number"],
|
|
1040
|
+
compare: Compare.Equal,
|
|
1041
|
+
value: 123n,
|
|
1125
1042
|
}),
|
|
1126
|
-
)
|
|
1127
|
-
).
|
|
1043
|
+
})
|
|
1044
|
+
).length,
|
|
1128
1045
|
).to.equal(0);
|
|
1129
1046
|
});
|
|
1130
1047
|
});
|
|
@@ -1136,78 +1053,69 @@ export const tests = (
|
|
|
1136
1053
|
});
|
|
1137
1054
|
|
|
1138
1055
|
it("and", async () => {
|
|
1139
|
-
const responses = await search(
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
responses.results.map((x) => x.id.primitive),
|
|
1163
|
-
).to.have.members(["1", "2"]);
|
|
1056
|
+
const responses = await search(store, {
|
|
1057
|
+
query: [
|
|
1058
|
+
new And([
|
|
1059
|
+
new StringMatch({
|
|
1060
|
+
key: "name",
|
|
1061
|
+
value: "hello",
|
|
1062
|
+
caseInsensitive: true,
|
|
1063
|
+
method: StringMatchMethod.contains,
|
|
1064
|
+
}),
|
|
1065
|
+
new StringMatch({
|
|
1066
|
+
key: "name",
|
|
1067
|
+
value: "world",
|
|
1068
|
+
caseInsensitive: true,
|
|
1069
|
+
method: StringMatchMethod.contains,
|
|
1070
|
+
}),
|
|
1071
|
+
]),
|
|
1072
|
+
],
|
|
1073
|
+
});
|
|
1074
|
+
expect(responses).to.have.length(2);
|
|
1075
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
1076
|
+
"1",
|
|
1077
|
+
"2",
|
|
1078
|
+
]);
|
|
1164
1079
|
});
|
|
1165
1080
|
|
|
1166
1081
|
it("or", async () => {
|
|
1167
|
-
const responses = await search(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
responses.results.map((x) => x.id.primitive),
|
|
1187
|
-
).to.have.members(["1", "2"]);
|
|
1082
|
+
const responses = await search(store, {
|
|
1083
|
+
query: [
|
|
1084
|
+
new Or([
|
|
1085
|
+
new StringMatch({
|
|
1086
|
+
key: "id",
|
|
1087
|
+
value: "1",
|
|
1088
|
+
}),
|
|
1089
|
+
new StringMatch({
|
|
1090
|
+
key: "id",
|
|
1091
|
+
value: "2",
|
|
1092
|
+
}),
|
|
1093
|
+
]),
|
|
1094
|
+
],
|
|
1095
|
+
});
|
|
1096
|
+
expect(responses).to.have.length(2);
|
|
1097
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members([
|
|
1098
|
+
"1",
|
|
1099
|
+
"2",
|
|
1100
|
+
]);
|
|
1188
1101
|
});
|
|
1189
1102
|
|
|
1190
1103
|
it("not", async () => {
|
|
1191
|
-
const responses = await search(
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
);
|
|
1207
|
-
expect(responses.results).to.have.length(1);
|
|
1208
|
-
expect(
|
|
1209
|
-
responses.results.map((x) => x.id.primitive),
|
|
1210
|
-
).to.have.members(["1"]);
|
|
1104
|
+
const responses = await search(store, {
|
|
1105
|
+
query: [
|
|
1106
|
+
new And([
|
|
1107
|
+
new Not(
|
|
1108
|
+
new IntegerCompare({
|
|
1109
|
+
key: "number",
|
|
1110
|
+
compare: Compare.Greater,
|
|
1111
|
+
value: 1n,
|
|
1112
|
+
}),
|
|
1113
|
+
),
|
|
1114
|
+
]),
|
|
1115
|
+
],
|
|
1116
|
+
});
|
|
1117
|
+
expect(responses).to.have.length(1);
|
|
1118
|
+
expect(responses.map((x) => x.id.primitive)).to.have.members(["1"]);
|
|
1211
1119
|
});
|
|
1212
1120
|
});
|
|
1213
1121
|
|
|
@@ -1216,96 +1124,81 @@ export const tests = (
|
|
|
1216
1124
|
await setupDefault();
|
|
1217
1125
|
});
|
|
1218
1126
|
it("equal", async () => {
|
|
1219
|
-
const response = await search(
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
);
|
|
1231
|
-
expect(response.results).to.have.length(1);
|
|
1232
|
-
expect(response.results[0].value.number).to.be.oneOf([2n, 2]);
|
|
1127
|
+
const response = await search(store, {
|
|
1128
|
+
query: [
|
|
1129
|
+
new IntegerCompare({
|
|
1130
|
+
key: "number",
|
|
1131
|
+
compare: Compare.Equal,
|
|
1132
|
+
value: 2n,
|
|
1133
|
+
}),
|
|
1134
|
+
],
|
|
1135
|
+
});
|
|
1136
|
+
expect(response).to.have.length(1);
|
|
1137
|
+
expect(response[0].value.number).to.be.oneOf([2n, 2]);
|
|
1233
1138
|
});
|
|
1234
1139
|
|
|
1235
1140
|
it("gt", async () => {
|
|
1236
|
-
const response = await search(
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
);
|
|
1248
|
-
expect(response.results).to.have.length(1);
|
|
1249
|
-
expect(response.results[0].value.number).to.be.oneOf([3n, 3]);
|
|
1141
|
+
const response = await search(store, {
|
|
1142
|
+
query: [
|
|
1143
|
+
new IntegerCompare({
|
|
1144
|
+
key: "number",
|
|
1145
|
+
compare: Compare.Greater,
|
|
1146
|
+
value: 2n,
|
|
1147
|
+
}),
|
|
1148
|
+
],
|
|
1149
|
+
});
|
|
1150
|
+
expect(response).to.have.length(1);
|
|
1151
|
+
expect(response[0].value.number).to.be.oneOf([3n, 3]);
|
|
1250
1152
|
});
|
|
1251
1153
|
|
|
1252
1154
|
it("gte", async () => {
|
|
1253
|
-
const response = await search(
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
}),
|
|
1264
|
-
);
|
|
1265
|
-
response.results.sort((a, b) =>
|
|
1155
|
+
const response = await search(store, {
|
|
1156
|
+
query: [
|
|
1157
|
+
new IntegerCompare({
|
|
1158
|
+
key: "number",
|
|
1159
|
+
compare: Compare.GreaterOrEqual,
|
|
1160
|
+
value: 2n,
|
|
1161
|
+
}),
|
|
1162
|
+
],
|
|
1163
|
+
});
|
|
1164
|
+
response.sort((a, b) =>
|
|
1266
1165
|
bigIntSort(a.value.number as bigint, b.value.number as bigint),
|
|
1267
1166
|
);
|
|
1268
|
-
expect(response
|
|
1269
|
-
expect(response
|
|
1270
|
-
expect(response
|
|
1167
|
+
expect(response).to.have.length(2);
|
|
1168
|
+
expect(response[0].value.number).to.be.oneOf([2n, 2]);
|
|
1169
|
+
expect(response[1].value.number).to.be.oneOf([3n, 3]);
|
|
1271
1170
|
});
|
|
1272
1171
|
|
|
1273
1172
|
it("lt", async () => {
|
|
1274
|
-
const response = await search(
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
);
|
|
1286
|
-
expect(response.results).to.have.length(1);
|
|
1287
|
-
expect(response.results[0].value.number).to.be.oneOf([1n, 1]);
|
|
1173
|
+
const response = await search(store, {
|
|
1174
|
+
query: [
|
|
1175
|
+
new IntegerCompare({
|
|
1176
|
+
key: "number",
|
|
1177
|
+
compare: Compare.Less,
|
|
1178
|
+
value: 2n,
|
|
1179
|
+
}),
|
|
1180
|
+
],
|
|
1181
|
+
});
|
|
1182
|
+
expect(response).to.have.length(1);
|
|
1183
|
+
expect(response[0].value.number).to.be.oneOf([1n, 1]);
|
|
1288
1184
|
});
|
|
1289
1185
|
|
|
1290
1186
|
it("lte", async () => {
|
|
1291
|
-
const response = await search(
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
}),
|
|
1302
|
-
);
|
|
1303
|
-
response.results.sort((a, b) =>
|
|
1187
|
+
const response = await search(store, {
|
|
1188
|
+
query: [
|
|
1189
|
+
new IntegerCompare({
|
|
1190
|
+
key: "number",
|
|
1191
|
+
compare: Compare.LessOrEqual,
|
|
1192
|
+
value: 2n,
|
|
1193
|
+
}),
|
|
1194
|
+
],
|
|
1195
|
+
});
|
|
1196
|
+
response.sort((a, b) =>
|
|
1304
1197
|
bigIntSort(a.value.number as bigint, b.value.number as bigint),
|
|
1305
1198
|
);
|
|
1306
|
-
expect(response
|
|
1307
|
-
expect(response
|
|
1308
|
-
expect(response
|
|
1199
|
+
expect(response).to.have.length(2);
|
|
1200
|
+
expect(response[0].value.number).to.be.oneOf([1n, 1]);
|
|
1201
|
+
expect(response[1].value.number).to.be.oneOf([2n, 2]);
|
|
1309
1202
|
});
|
|
1310
1203
|
});
|
|
1311
1204
|
|
|
@@ -1340,97 +1233,82 @@ export const tests = (
|
|
|
1340
1233
|
});
|
|
1341
1234
|
|
|
1342
1235
|
it("equal", async () => {
|
|
1343
|
-
const response = await search(
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
);
|
|
1355
|
-
expect(response.results).to.have.length(1);
|
|
1356
|
-
expect(response.results[0].value.bigint).to.equal(first);
|
|
1236
|
+
const response = await search(store, {
|
|
1237
|
+
query: [
|
|
1238
|
+
new IntegerCompare({
|
|
1239
|
+
key: "bigint",
|
|
1240
|
+
compare: Compare.Equal,
|
|
1241
|
+
value: first,
|
|
1242
|
+
}),
|
|
1243
|
+
],
|
|
1244
|
+
});
|
|
1245
|
+
expect(response).to.have.length(1);
|
|
1246
|
+
expect(response[0].value.bigint).to.equal(first);
|
|
1357
1247
|
});
|
|
1358
1248
|
|
|
1359
1249
|
it("gt", async () => {
|
|
1360
|
-
const response = await search(
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
);
|
|
1372
|
-
expect(response.results).to.have.length(1);
|
|
1373
|
-
expect(response.results[0].value.bigint).to.equal(third);
|
|
1250
|
+
const response = await search(store, {
|
|
1251
|
+
query: [
|
|
1252
|
+
new IntegerCompare({
|
|
1253
|
+
key: "bigint",
|
|
1254
|
+
compare: Compare.Greater,
|
|
1255
|
+
value: second,
|
|
1256
|
+
}),
|
|
1257
|
+
],
|
|
1258
|
+
});
|
|
1259
|
+
expect(response).to.have.length(1);
|
|
1260
|
+
expect(response[0].value.bigint).to.equal(third);
|
|
1374
1261
|
});
|
|
1375
1262
|
|
|
1376
1263
|
it("gte", async () => {
|
|
1377
|
-
const response = await search(
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
}),
|
|
1388
|
-
);
|
|
1389
|
-
response.results.sort((a, b) =>
|
|
1264
|
+
const response = await search(store, {
|
|
1265
|
+
query: [
|
|
1266
|
+
new IntegerCompare({
|
|
1267
|
+
key: "bigint",
|
|
1268
|
+
compare: Compare.GreaterOrEqual,
|
|
1269
|
+
value: second,
|
|
1270
|
+
}),
|
|
1271
|
+
],
|
|
1272
|
+
});
|
|
1273
|
+
response.sort((a, b) =>
|
|
1390
1274
|
bigIntSort(a.value.bigint as bigint, b.value.bigint as bigint),
|
|
1391
1275
|
);
|
|
1392
|
-
expect(response
|
|
1393
|
-
expect(response
|
|
1394
|
-
expect(response
|
|
1276
|
+
expect(response).to.have.length(2);
|
|
1277
|
+
expect(response[0].value.bigint).to.equal(second);
|
|
1278
|
+
expect(response[1].value.bigint).to.equal(third);
|
|
1395
1279
|
});
|
|
1396
1280
|
|
|
1397
1281
|
it("lt", async () => {
|
|
1398
|
-
const response = await search(
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
);
|
|
1410
|
-
expect(response.results).to.have.length(1);
|
|
1411
|
-
expect(response.results[0].value.bigint).to.equal(first);
|
|
1282
|
+
const response = await search(store, {
|
|
1283
|
+
query: [
|
|
1284
|
+
new IntegerCompare({
|
|
1285
|
+
key: "bigint",
|
|
1286
|
+
compare: Compare.Less,
|
|
1287
|
+
value: second,
|
|
1288
|
+
}),
|
|
1289
|
+
],
|
|
1290
|
+
});
|
|
1291
|
+
expect(response).to.have.length(1);
|
|
1292
|
+
expect(response[0].value.bigint).to.equal(first);
|
|
1412
1293
|
});
|
|
1413
1294
|
|
|
1414
1295
|
it("lte", async () => {
|
|
1415
|
-
const response = await search(
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
}),
|
|
1426
|
-
);
|
|
1427
|
-
response.results.sort((a, b) =>
|
|
1296
|
+
const response = await search(store, {
|
|
1297
|
+
query: [
|
|
1298
|
+
new IntegerCompare({
|
|
1299
|
+
key: "bigint",
|
|
1300
|
+
compare: Compare.LessOrEqual,
|
|
1301
|
+
value: second,
|
|
1302
|
+
}),
|
|
1303
|
+
],
|
|
1304
|
+
});
|
|
1305
|
+
response.sort((a, b) =>
|
|
1428
1306
|
bigIntSort(a.value.number as bigint, b.value.number as bigint),
|
|
1429
1307
|
);
|
|
1430
1308
|
|
|
1431
|
-
expect(response
|
|
1432
|
-
expect(response
|
|
1433
|
-
expect(response
|
|
1309
|
+
expect(response).to.have.length(2);
|
|
1310
|
+
expect(response[0].value.bigint).to.equal(first);
|
|
1311
|
+
expect(response[1].value.bigint).to.equal(second);
|
|
1434
1312
|
});
|
|
1435
1313
|
});
|
|
1436
1314
|
|
|
@@ -1480,22 +1358,19 @@ export const tests = (
|
|
|
1480
1358
|
});
|
|
1481
1359
|
await store.put(doc2);
|
|
1482
1360
|
|
|
1483
|
-
const response = await search(
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
);
|
|
1495
|
-
expect(response.results).to.have.length(1);
|
|
1496
|
-
expect(response.results[0].value.id).to.equal("2");
|
|
1361
|
+
const response = await search(store, {
|
|
1362
|
+
query: [
|
|
1363
|
+
new IntegerCompare({
|
|
1364
|
+
key: ["nested", "number"],
|
|
1365
|
+
compare: Compare.GreaterOrEqual,
|
|
1366
|
+
value: 2n,
|
|
1367
|
+
}),
|
|
1368
|
+
],
|
|
1369
|
+
});
|
|
1370
|
+
expect(response).to.have.length(1);
|
|
1371
|
+
expect(response[0].value.id).to.equal("2");
|
|
1497
1372
|
|
|
1498
|
-
checkDocument(response
|
|
1373
|
+
checkDocument(response[0].value, doc2);
|
|
1499
1374
|
});
|
|
1500
1375
|
|
|
1501
1376
|
it("bool", async () => {
|
|
@@ -1511,35 +1386,29 @@ export const tests = (
|
|
|
1511
1386
|
});
|
|
1512
1387
|
|
|
1513
1388
|
await store.put(doc2);
|
|
1514
|
-
let response = await search(
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
);
|
|
1525
|
-
expect(response.results).to.have.length(1);
|
|
1526
|
-
expect(response.results[0].value.id).to.equal("2");
|
|
1527
|
-
checkDocument(response.results[0].value, doc2);
|
|
1389
|
+
let response = await search(store, {
|
|
1390
|
+
query: [
|
|
1391
|
+
new BoolQuery({
|
|
1392
|
+
key: ["nested", "bool"],
|
|
1393
|
+
value: true,
|
|
1394
|
+
}),
|
|
1395
|
+
],
|
|
1396
|
+
});
|
|
1397
|
+
expect(response).to.have.length(1);
|
|
1398
|
+
expect(response[0].value.id).to.equal("2");
|
|
1399
|
+
checkDocument(response[0].value, doc2);
|
|
1528
1400
|
|
|
1529
|
-
response = await search(
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
);
|
|
1540
|
-
expect(response.results).to.have.length(1);
|
|
1541
|
-
expect(response.results[0].value.id).to.equal("1");
|
|
1542
|
-
checkDocument(response.results[0].value, doc1);
|
|
1401
|
+
response = await search(store, {
|
|
1402
|
+
query: [
|
|
1403
|
+
new BoolQuery({
|
|
1404
|
+
key: ["nested", "bool"],
|
|
1405
|
+
value: false,
|
|
1406
|
+
}),
|
|
1407
|
+
],
|
|
1408
|
+
});
|
|
1409
|
+
expect(response).to.have.length(1);
|
|
1410
|
+
expect(response[0].value.id).to.equal("1");
|
|
1411
|
+
checkDocument(response[0].value, doc1);
|
|
1543
1412
|
});
|
|
1544
1413
|
});
|
|
1545
1414
|
|
|
@@ -1584,35 +1453,29 @@ export const tests = (
|
|
|
1584
1453
|
});
|
|
1585
1454
|
|
|
1586
1455
|
await store.put(doc2);
|
|
1587
|
-
let response = await search(
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
);
|
|
1598
|
-
expect(response.results).to.have.length(1);
|
|
1599
|
-
expect(response.results[0].value.id).to.equal("2");
|
|
1600
|
-
checkDocument(response.results[0].value, doc2);
|
|
1456
|
+
let response = await search(store, {
|
|
1457
|
+
query: [
|
|
1458
|
+
new BoolQuery({
|
|
1459
|
+
key: ["nested", "bool"],
|
|
1460
|
+
value: true,
|
|
1461
|
+
}),
|
|
1462
|
+
],
|
|
1463
|
+
});
|
|
1464
|
+
expect(response).to.have.length(1);
|
|
1465
|
+
expect(response[0].value.id).to.equal("2");
|
|
1466
|
+
checkDocument(response[0].value, doc2);
|
|
1601
1467
|
|
|
1602
|
-
response = await search(
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
);
|
|
1613
|
-
expect(response.results).to.have.length(1);
|
|
1614
|
-
expect(response.results[0].value.id).to.equal("1");
|
|
1615
|
-
checkDocument(response.results[0].value, doc1);
|
|
1468
|
+
response = await search(store, {
|
|
1469
|
+
query: [
|
|
1470
|
+
new BoolQuery({
|
|
1471
|
+
key: ["nested", "bool"],
|
|
1472
|
+
value: false,
|
|
1473
|
+
}),
|
|
1474
|
+
],
|
|
1475
|
+
});
|
|
1476
|
+
expect(response).to.have.length(1);
|
|
1477
|
+
expect(response[0].value.id).to.equal("1");
|
|
1478
|
+
checkDocument(response[0].value, doc1);
|
|
1616
1479
|
});
|
|
1617
1480
|
});
|
|
1618
1481
|
|
|
@@ -1670,22 +1533,19 @@ export const tests = (
|
|
|
1670
1533
|
});
|
|
1671
1534
|
await store.put(doc2);
|
|
1672
1535
|
|
|
1673
|
-
const response = await search(
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
);
|
|
1685
|
-
expect(response.results).to.have.length(1);
|
|
1686
|
-
expect(response.results[0].value.id).to.equal("2");
|
|
1536
|
+
const response = await search(store, {
|
|
1537
|
+
query: [
|
|
1538
|
+
new IntegerCompare({
|
|
1539
|
+
key: ["nested", "nestedAgain", "number"],
|
|
1540
|
+
compare: Compare.GreaterOrEqual,
|
|
1541
|
+
value: 2n,
|
|
1542
|
+
}),
|
|
1543
|
+
],
|
|
1544
|
+
});
|
|
1545
|
+
expect(response).to.have.length(1);
|
|
1546
|
+
expect(response[0].value.id).to.equal("2");
|
|
1687
1547
|
|
|
1688
|
-
checkDocument(response
|
|
1548
|
+
checkDocument(response[0].value, doc2);
|
|
1689
1549
|
});
|
|
1690
1550
|
});
|
|
1691
1551
|
|
|
@@ -1756,27 +1616,24 @@ export const tests = (
|
|
|
1756
1616
|
});
|
|
1757
1617
|
await store.put(doc2);
|
|
1758
1618
|
|
|
1759
|
-
const response = await search(
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
],
|
|
1774
|
-
}),
|
|
1775
|
-
);
|
|
1619
|
+
const response = await search(store, {
|
|
1620
|
+
query: [
|
|
1621
|
+
new IntegerCompare({
|
|
1622
|
+
key: [
|
|
1623
|
+
"nested",
|
|
1624
|
+
"nestedAgain",
|
|
1625
|
+
"nestedAgainAgain",
|
|
1626
|
+
"number",
|
|
1627
|
+
],
|
|
1628
|
+
compare: Compare.GreaterOrEqual,
|
|
1629
|
+
value: 2n,
|
|
1630
|
+
}),
|
|
1631
|
+
],
|
|
1632
|
+
});
|
|
1776
1633
|
|
|
1777
|
-
expect(response
|
|
1778
|
-
expect(response
|
|
1779
|
-
checkDocument(response
|
|
1634
|
+
expect(response).to.have.length(1);
|
|
1635
|
+
expect(response[0].value.id).to.equal("2");
|
|
1636
|
+
checkDocument(response[0].value, doc2);
|
|
1780
1637
|
});
|
|
1781
1638
|
});
|
|
1782
1639
|
|
|
@@ -1841,22 +1698,19 @@ export const tests = (
|
|
|
1841
1698
|
});
|
|
1842
1699
|
await store.put(doc2);
|
|
1843
1700
|
|
|
1844
|
-
const response = await search(
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
],
|
|
1853
|
-
}),
|
|
1854
|
-
);
|
|
1855
|
-
|
|
1856
|
-
expect(response.results).to.have.length(1);
|
|
1857
|
-
expect(response.results[0].value.id).to.equal("2");
|
|
1701
|
+
const response = await search(store, {
|
|
1702
|
+
query: [
|
|
1703
|
+
new StringMatch({
|
|
1704
|
+
key: ["nested", "string"],
|
|
1705
|
+
value: "hello",
|
|
1706
|
+
}),
|
|
1707
|
+
],
|
|
1708
|
+
});
|
|
1858
1709
|
|
|
1859
|
-
|
|
1710
|
+
expect(response).to.have.length(1);
|
|
1711
|
+
expect(response[0].value.id).to.equal("2");
|
|
1712
|
+
|
|
1713
|
+
checkDocument(response[0].value, doc2);
|
|
1860
1714
|
});
|
|
1861
1715
|
});
|
|
1862
1716
|
|
|
@@ -1934,22 +1788,19 @@ export const tests = (
|
|
|
1934
1788
|
});
|
|
1935
1789
|
await store.put(doc2);
|
|
1936
1790
|
|
|
1937
|
-
const response = await search(
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
],
|
|
1946
|
-
}),
|
|
1947
|
-
);
|
|
1791
|
+
const response = await search(store, {
|
|
1792
|
+
query: [
|
|
1793
|
+
new StringMatch({
|
|
1794
|
+
key: ["nested", "nestedAgain", "string"],
|
|
1795
|
+
value: "hello",
|
|
1796
|
+
}),
|
|
1797
|
+
],
|
|
1798
|
+
});
|
|
1948
1799
|
|
|
1949
|
-
expect(response
|
|
1950
|
-
expect(response
|
|
1800
|
+
expect(response).to.have.length(1);
|
|
1801
|
+
expect(response[0].value.id).to.equal("2");
|
|
1951
1802
|
|
|
1952
|
-
checkDocument(response
|
|
1803
|
+
checkDocument(response[0].value, doc2);
|
|
1953
1804
|
});
|
|
1954
1805
|
});
|
|
1955
1806
|
|
|
@@ -2026,21 +1877,18 @@ export const tests = (
|
|
|
2026
1877
|
|
|
2027
1878
|
await store.put(doc2);
|
|
2028
1879
|
|
|
2029
|
-
const response = await search(
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
],
|
|
2038
|
-
}),
|
|
2039
|
-
);
|
|
1880
|
+
const response = await search(store, {
|
|
1881
|
+
query: [
|
|
1882
|
+
new StringMatch({
|
|
1883
|
+
key: ["array", "string"],
|
|
1884
|
+
value: "world",
|
|
1885
|
+
}),
|
|
1886
|
+
],
|
|
1887
|
+
});
|
|
2040
1888
|
|
|
2041
|
-
expect(response
|
|
2042
|
-
expect(response
|
|
2043
|
-
checkDocument(response
|
|
1889
|
+
expect(response).to.have.length(1);
|
|
1890
|
+
expect(response[0].value.id).to.equal("2");
|
|
1891
|
+
checkDocument(response[0].value, doc2);
|
|
2044
1892
|
});
|
|
2045
1893
|
});
|
|
2046
1894
|
|
|
@@ -2107,21 +1955,18 @@ export const tests = (
|
|
|
2107
1955
|
|
|
2108
1956
|
await store.put(doc2);
|
|
2109
1957
|
|
|
2110
|
-
const response = await search(
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
],
|
|
2119
|
-
}),
|
|
2120
|
-
);
|
|
1958
|
+
const response = await search(store, {
|
|
1959
|
+
query: [
|
|
1960
|
+
new StringMatch({
|
|
1961
|
+
key: ["base", "string"],
|
|
1962
|
+
value: "world",
|
|
1963
|
+
}),
|
|
1964
|
+
],
|
|
1965
|
+
});
|
|
2121
1966
|
|
|
2122
|
-
expect(response
|
|
2123
|
-
expect(response
|
|
2124
|
-
checkDocument(response
|
|
1967
|
+
expect(response).to.have.length(1);
|
|
1968
|
+
expect(response[0].value.id).to.equal("2");
|
|
1969
|
+
checkDocument(response[0].value, doc2);
|
|
2125
1970
|
});
|
|
2126
1971
|
});
|
|
2127
1972
|
|
|
@@ -2171,23 +2016,20 @@ export const tests = (
|
|
|
2171
2016
|
});
|
|
2172
2017
|
await store.put(doc2);
|
|
2173
2018
|
|
|
2174
|
-
const response = await search(
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
],
|
|
2183
|
-
}),
|
|
2184
|
-
);
|
|
2019
|
+
const response = await search(store, {
|
|
2020
|
+
query: [
|
|
2021
|
+
new StringMatch({
|
|
2022
|
+
key: ["nested", "arr"],
|
|
2023
|
+
value: "värld",
|
|
2024
|
+
}),
|
|
2025
|
+
],
|
|
2026
|
+
});
|
|
2185
2027
|
|
|
2186
|
-
expect(response
|
|
2187
|
-
expect(
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
checkDocument(response
|
|
2028
|
+
expect(response).to.have.length(1);
|
|
2029
|
+
expect(response.map((x) => x.value.id)).to.have.members([
|
|
2030
|
+
"2",
|
|
2031
|
+
]);
|
|
2032
|
+
checkDocument(response[0].value, doc2);
|
|
2191
2033
|
});
|
|
2192
2034
|
});
|
|
2193
2035
|
|
|
@@ -2250,30 +2092,27 @@ export const tests = (
|
|
|
2250
2092
|
}),
|
|
2251
2093
|
);
|
|
2252
2094
|
|
|
2253
|
-
const response = await search(
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
new
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
],
|
|
2271
|
-
}),
|
|
2272
|
-
);
|
|
2095
|
+
const response = await search(store, {
|
|
2096
|
+
query: [
|
|
2097
|
+
new Nested({
|
|
2098
|
+
path: "array",
|
|
2099
|
+
query: new And([
|
|
2100
|
+
new StringMatch({
|
|
2101
|
+
key: "a",
|
|
2102
|
+
value: "hello",
|
|
2103
|
+
}),
|
|
2104
|
+
new StringMatch({
|
|
2105
|
+
key: "b",
|
|
2106
|
+
value: "world",
|
|
2107
|
+
}),
|
|
2108
|
+
]),
|
|
2109
|
+
}),
|
|
2110
|
+
],
|
|
2111
|
+
});
|
|
2273
2112
|
|
|
2274
|
-
expect(response
|
|
2275
|
-
expect(response
|
|
2276
|
-
checkDocument(response
|
|
2113
|
+
expect(response).to.have.length(1);
|
|
2114
|
+
expect(response[0].value.id).to.equal("1");
|
|
2115
|
+
checkDocument(response[0].value, doc1);
|
|
2277
2116
|
});
|
|
2278
2117
|
|
|
2279
2118
|
it("nested partial match", async () => {
|
|
@@ -2305,24 +2144,21 @@ export const tests = (
|
|
|
2305
2144
|
}),
|
|
2306
2145
|
);
|
|
2307
2146
|
|
|
2308
|
-
const response = await search(
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
],
|
|
2321
|
-
}),
|
|
2322
|
-
);
|
|
2147
|
+
const response = await search(store, {
|
|
2148
|
+
query: [
|
|
2149
|
+
new StringMatch({
|
|
2150
|
+
key: ["array", "a"],
|
|
2151
|
+
value: "hello",
|
|
2152
|
+
}),
|
|
2153
|
+
new StringMatch({
|
|
2154
|
+
key: ["array", "b"],
|
|
2155
|
+
value: "world",
|
|
2156
|
+
}),
|
|
2157
|
+
],
|
|
2158
|
+
});
|
|
2323
2159
|
|
|
2324
|
-
expect(response
|
|
2325
|
-
checkDocument(response
|
|
2160
|
+
expect(response).to.have.length(2);
|
|
2161
|
+
checkDocument(response[0].value, doc1);
|
|
2326
2162
|
});
|
|
2327
2163
|
});
|
|
2328
2164
|
});
|
|
@@ -2337,15 +2173,12 @@ export const tests = (
|
|
|
2337
2173
|
it("can query one of the version", async () => {
|
|
2338
2174
|
await store.put(new DocumentNext({ anotherField: "hello" }));
|
|
2339
2175
|
|
|
2340
|
-
const result = await search(
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
}),
|
|
2345
|
-
);
|
|
2346
|
-
expect(result.results).to.have.length(1);
|
|
2176
|
+
const result = await search(store, {
|
|
2177
|
+
query: new StringMatch({ key: "anotherField", value: "hello" }),
|
|
2178
|
+
});
|
|
2179
|
+
expect(result).to.have.length(1);
|
|
2347
2180
|
|
|
2348
|
-
const [doc] = result
|
|
2181
|
+
const [doc] = result;
|
|
2349
2182
|
expect(doc.value).to.be.instanceOf(DocumentNext);
|
|
2350
2183
|
});
|
|
2351
2184
|
|
|
@@ -2354,15 +2187,12 @@ export const tests = (
|
|
|
2354
2187
|
await store.put(new DocumentNext({ name }));
|
|
2355
2188
|
await store.put(new DocumentNext({ name }));
|
|
2356
2189
|
|
|
2357
|
-
const result = await search(
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
query: new StringMatch({ key: "name", value: name }),
|
|
2361
|
-
}),
|
|
2362
|
-
);
|
|
2190
|
+
const result = await search(store, {
|
|
2191
|
+
query: new StringMatch({ key: "name", value: name }),
|
|
2192
|
+
});
|
|
2363
2193
|
|
|
2364
|
-
expect(result
|
|
2365
|
-
for (const doc of result
|
|
2194
|
+
expect(result).to.have.length(2);
|
|
2195
|
+
for (const doc of result) {
|
|
2366
2196
|
expect(doc.value).to.be.instanceOf(DocumentNext);
|
|
2367
2197
|
}
|
|
2368
2198
|
});
|
|
@@ -2377,11 +2207,11 @@ export const tests = (
|
|
|
2377
2207
|
it("filter field", async () => {
|
|
2378
2208
|
const results = await search(
|
|
2379
2209
|
store,
|
|
2380
|
-
|
|
2210
|
+
{ query: [] },
|
|
2381
2211
|
{ shape: { id: true } },
|
|
2382
2212
|
);
|
|
2383
|
-
expect(results
|
|
2384
|
-
for (const result of results
|
|
2213
|
+
expect(results).to.have.length(4);
|
|
2214
|
+
for (const result of results) {
|
|
2385
2215
|
if (shapingSupported) {
|
|
2386
2216
|
expect(Object.keys(result.value)).to.have.length(1);
|
|
2387
2217
|
expect(result.value["id"]).to.exist;
|
|
@@ -2397,11 +2227,11 @@ export const tests = (
|
|
|
2397
2227
|
it("nested field", async () => {
|
|
2398
2228
|
const results = await search(
|
|
2399
2229
|
store,
|
|
2400
|
-
|
|
2401
|
-
{ shape: { nestedVec: { number: true } } },
|
|
2230
|
+
{ query: [] },
|
|
2231
|
+
{ shape: { nestedVec: [{ number: true }] } },
|
|
2402
2232
|
);
|
|
2403
|
-
expect(results
|
|
2404
|
-
for (const value of results
|
|
2233
|
+
expect(results).to.have.length(4);
|
|
2234
|
+
for (const value of results) {
|
|
2405
2235
|
const arr = value.value["nestedVec"];
|
|
2406
2236
|
expect(arr).to.be.exist;
|
|
2407
2237
|
|
|
@@ -2470,29 +2300,31 @@ export const tests = (
|
|
|
2470
2300
|
),
|
|
2471
2301
|
);
|
|
2472
2302
|
|
|
2473
|
-
const shapedResults = await
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2303
|
+
const shapedResults = await index.store
|
|
2304
|
+
.iterate(
|
|
2305
|
+
{
|
|
2306
|
+
query: new BoolQuery({
|
|
2307
|
+
key: ["nested", "bool"],
|
|
2308
|
+
value: false,
|
|
2309
|
+
}),
|
|
2310
|
+
},
|
|
2311
|
+
{ shape: { id: true } },
|
|
2312
|
+
)
|
|
2313
|
+
.all();
|
|
2480
2314
|
expect(shapedResults).to.have.length(1);
|
|
2481
2315
|
expect(shapedResults[0].value.id).to.equal("2");
|
|
2482
2316
|
|
|
2483
2317
|
if (shapingSupported) {
|
|
2484
|
-
expect(shapedResults[0].value
|
|
2318
|
+
expect(shapedResults[0].value["nested"]).to.be.undefined;
|
|
2485
2319
|
} else {
|
|
2486
|
-
expect(shapedResults[0].value
|
|
2320
|
+
expect(shapedResults[0].value["nested"]).to.exist;
|
|
2487
2321
|
}
|
|
2488
2322
|
|
|
2489
|
-
const unshapedResults = await
|
|
2490
|
-
|
|
2491
|
-
new SearchRequest({
|
|
2323
|
+
const unshapedResults = await index.store
|
|
2324
|
+
.iterate({
|
|
2492
2325
|
query: new BoolQuery({ key: ["nested", "bool"], value: false }),
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
).all();
|
|
2326
|
+
})
|
|
2327
|
+
.all();
|
|
2496
2328
|
expect(unshapedResults).to.have.length(1);
|
|
2497
2329
|
expect(unshapedResults[0].value.id).to.equal("2");
|
|
2498
2330
|
expect(unshapedResults[0].value.nested).to.exist;
|
|
@@ -2513,24 +2345,24 @@ export const tests = (
|
|
|
2513
2345
|
await index.store.put(d1);
|
|
2514
2346
|
await index.store.put(d2);
|
|
2515
2347
|
|
|
2516
|
-
const unshapedResults = await
|
|
2517
|
-
|
|
2518
|
-
new SearchRequest({
|
|
2348
|
+
const unshapedResults = await index.store
|
|
2349
|
+
.iterate({
|
|
2519
2350
|
query: new StringMatch({ key: ["id"], value: "2" }),
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
).all();
|
|
2351
|
+
})
|
|
2352
|
+
.all();
|
|
2523
2353
|
expect(unshapedResults).to.have.length(1);
|
|
2524
2354
|
expect(unshapedResults[0].value.id).to.equal(d2.id);
|
|
2525
2355
|
expect(unshapedResults[0].value.nested).to.deep.equal(d2.nested);
|
|
2526
2356
|
|
|
2527
|
-
const shapedResults = await
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2357
|
+
const shapedResults = await index.store
|
|
2358
|
+
.iterate(
|
|
2359
|
+
{
|
|
2360
|
+
query: new StringMatch({ key: ["id"], value: "2" }),
|
|
2361
|
+
},
|
|
2362
|
+
{ shape: { id: true, nested: { bool: true } } },
|
|
2363
|
+
)
|
|
2364
|
+
.all();
|
|
2365
|
+
|
|
2534
2366
|
expect(shapedResults).to.have.length(1);
|
|
2535
2367
|
expect(shapedResults[0].value.id).to.equal(d2.id);
|
|
2536
2368
|
|
|
@@ -2620,31 +2452,35 @@ export const tests = (
|
|
|
2620
2452
|
),
|
|
2621
2453
|
);
|
|
2622
2454
|
|
|
2623
|
-
const shapedResults = await
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2455
|
+
const shapedResults = await index.store
|
|
2456
|
+
.iterate(
|
|
2457
|
+
{
|
|
2458
|
+
query: new BoolQuery({
|
|
2459
|
+
key: ["nested", "bool"],
|
|
2460
|
+
value: false,
|
|
2461
|
+
}),
|
|
2462
|
+
},
|
|
2463
|
+
{ shape: { id: true } },
|
|
2464
|
+
)
|
|
2465
|
+
.all();
|
|
2630
2466
|
expect(shapedResults).to.have.length(1);
|
|
2631
2467
|
expect(shapedResults[0].value.id).to.equal("2");
|
|
2632
2468
|
|
|
2633
2469
|
if (shapingSupported) {
|
|
2634
|
-
expect(shapedResults[0].value
|
|
2470
|
+
expect(shapedResults[0].value["nested"]).to.be.undefined;
|
|
2635
2471
|
} else {
|
|
2636
|
-
expect(shapedResults[0].value
|
|
2472
|
+
expect(shapedResults[0].value["nested"]).to.exist;
|
|
2637
2473
|
}
|
|
2638
2474
|
|
|
2639
|
-
const unshapedResults = await
|
|
2640
|
-
|
|
2641
|
-
new SearchRequest({
|
|
2475
|
+
const unshapedResults = await index.store
|
|
2476
|
+
.iterate({
|
|
2642
2477
|
query: new BoolQuery({ key: ["nested", "bool"], value: false }),
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2478
|
+
})
|
|
2479
|
+
.all();
|
|
2480
|
+
|
|
2646
2481
|
expect(unshapedResults).to.have.length(1);
|
|
2647
2482
|
expect(unshapedResults[0].value.id).to.equal("2");
|
|
2483
|
+
|
|
2648
2484
|
expect(unshapedResults[0].value.nested).to.exist;
|
|
2649
2485
|
});
|
|
2650
2486
|
|
|
@@ -2663,24 +2499,23 @@ export const tests = (
|
|
|
2663
2499
|
await index.store.put(d1);
|
|
2664
2500
|
await index.store.put(d2);
|
|
2665
2501
|
|
|
2666
|
-
const unshapedResults = await
|
|
2667
|
-
|
|
2668
|
-
new SearchRequest({
|
|
2502
|
+
const unshapedResults = await index.store
|
|
2503
|
+
.iterate({
|
|
2669
2504
|
query: new StringMatch({ key: ["id"], value: "2" }),
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
).all();
|
|
2505
|
+
})
|
|
2506
|
+
.all();
|
|
2673
2507
|
expect(unshapedResults).to.have.length(1);
|
|
2674
2508
|
expect(unshapedResults[0].value.id).to.equal(d2.id);
|
|
2675
2509
|
expect(unshapedResults[0].value.nested).to.deep.equal(d2.nested);
|
|
2676
2510
|
|
|
2677
|
-
const shapedResults = await
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2511
|
+
const shapedResults = await index.store
|
|
2512
|
+
.iterate(
|
|
2513
|
+
{
|
|
2514
|
+
query: new StringMatch({ key: ["id"], value: "2" }),
|
|
2515
|
+
},
|
|
2516
|
+
{ shape: { id: true, nested: { bool: true } } },
|
|
2517
|
+
)
|
|
2518
|
+
.all();
|
|
2684
2519
|
expect(shapedResults).to.have.length(1);
|
|
2685
2520
|
expect(shapedResults[0].value.id).to.equal(d2.id);
|
|
2686
2521
|
|
|
@@ -2747,29 +2582,31 @@ export const tests = (
|
|
|
2747
2582
|
),
|
|
2748
2583
|
);
|
|
2749
2584
|
|
|
2750
|
-
const shapedResults = await
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2585
|
+
const shapedResults = await index.store
|
|
2586
|
+
.iterate(
|
|
2587
|
+
{
|
|
2588
|
+
query: new BoolQuery({
|
|
2589
|
+
key: ["nested", "bool"],
|
|
2590
|
+
value: false,
|
|
2591
|
+
}),
|
|
2592
|
+
},
|
|
2593
|
+
{ shape: { id: true } },
|
|
2594
|
+
)
|
|
2595
|
+
.all();
|
|
2757
2596
|
expect(shapedResults).to.have.length(1);
|
|
2758
2597
|
expect(shapedResults[0].value.id).to.equal("2");
|
|
2759
2598
|
|
|
2760
2599
|
if (shapingSupported) {
|
|
2761
|
-
expect(shapedResults[0].value
|
|
2600
|
+
expect(shapedResults[0].value["nested"]).to.be.undefined;
|
|
2762
2601
|
} else {
|
|
2763
|
-
expect(shapedResults[0].value
|
|
2602
|
+
expect(shapedResults[0].value["nested"]).to.exist;
|
|
2764
2603
|
}
|
|
2765
2604
|
|
|
2766
|
-
const unshapedResults = await
|
|
2767
|
-
|
|
2768
|
-
new SearchRequest({
|
|
2605
|
+
const unshapedResults = await index.store
|
|
2606
|
+
.iterate({
|
|
2769
2607
|
query: new BoolQuery({ key: ["nested", "bool"], value: false }),
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
).all();
|
|
2608
|
+
})
|
|
2609
|
+
.all();
|
|
2773
2610
|
expect(unshapedResults).to.have.length(1);
|
|
2774
2611
|
expect(unshapedResults[0].value.id).to.equal("2");
|
|
2775
2612
|
expect(unshapedResults[0].value.nested).to.exist;
|
|
@@ -2790,13 +2627,14 @@ export const tests = (
|
|
|
2790
2627
|
await index.store.put(d1);
|
|
2791
2628
|
await index.store.put(d2);
|
|
2792
2629
|
|
|
2793
|
-
const shapedResults = await
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2630
|
+
const shapedResults = await index.store
|
|
2631
|
+
.iterate(
|
|
2632
|
+
{
|
|
2633
|
+
query: new StringMatch({ key: ["id"], value: "2" }),
|
|
2634
|
+
},
|
|
2635
|
+
{ shape: { id: true, nested: [{ bool: true }] } },
|
|
2636
|
+
)
|
|
2637
|
+
.all();
|
|
2800
2638
|
expect(shapedResults).to.have.length(1);
|
|
2801
2639
|
expect(shapedResults[0].value.id).to.equal(d2.id);
|
|
2802
2640
|
|
|
@@ -2810,19 +2648,43 @@ export const tests = (
|
|
|
2810
2648
|
);
|
|
2811
2649
|
}
|
|
2812
2650
|
|
|
2813
|
-
const unshapedResults = await
|
|
2814
|
-
|
|
2815
|
-
new SearchRequest({
|
|
2651
|
+
const unshapedResults = await index.store
|
|
2652
|
+
.iterate({
|
|
2816
2653
|
query: new StringMatch({ key: ["id"], value: "2" }),
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
).all();
|
|
2654
|
+
})
|
|
2655
|
+
.all();
|
|
2820
2656
|
expect(unshapedResults).to.have.length(1);
|
|
2821
2657
|
expect(unshapedResults[0].value.id).to.equal(d2.id);
|
|
2822
2658
|
expect(unshapedResults[0].value.nested[0]).to.deep.equal(
|
|
2823
2659
|
d2.nested[0],
|
|
2824
2660
|
);
|
|
2825
2661
|
});
|
|
2662
|
+
|
|
2663
|
+
it("true resolves fully", async () => {
|
|
2664
|
+
index = await setup({ schema: NestedBoolQueryDocument });
|
|
2665
|
+
|
|
2666
|
+
const d1 = new NestedBoolQueryDocument(
|
|
2667
|
+
"1",
|
|
2668
|
+
new MultifieldNested(true, 1, ["1"]),
|
|
2669
|
+
);
|
|
2670
|
+
|
|
2671
|
+
await index.store.put(d1);
|
|
2672
|
+
|
|
2673
|
+
const shapedResults = await index.store
|
|
2674
|
+
.iterate(
|
|
2675
|
+
{
|
|
2676
|
+
query: [],
|
|
2677
|
+
},
|
|
2678
|
+
{ shape: { id: true, nested: true } },
|
|
2679
|
+
)
|
|
2680
|
+
.all();
|
|
2681
|
+
expect(shapedResults).to.have.length(1);
|
|
2682
|
+
expect(shapedResults[0].value.id).to.equal(d1.id);
|
|
2683
|
+
|
|
2684
|
+
expect(shapedResults[0].value.nested[0]).to.deep.equal(
|
|
2685
|
+
d1.nested[0],
|
|
2686
|
+
);
|
|
2687
|
+
});
|
|
2826
2688
|
});
|
|
2827
2689
|
});
|
|
2828
2690
|
});
|
|
@@ -2853,24 +2715,30 @@ export const tests = (
|
|
|
2853
2715
|
],
|
|
2854
2716
|
) => {
|
|
2855
2717
|
await waitForResolved(async () => {
|
|
2856
|
-
const req =
|
|
2718
|
+
const req = {
|
|
2857
2719
|
query,
|
|
2858
2720
|
sort,
|
|
2859
|
-
}
|
|
2860
|
-
const iterator = iterate(
|
|
2721
|
+
};
|
|
2722
|
+
const iterator = store.iterate(req);
|
|
2723
|
+
|
|
2724
|
+
// No fetches has been made, so we don't know whether we are done yet
|
|
2725
|
+
expect(iterator.done()).to.be.undefined;
|
|
2861
2726
|
|
|
2862
2727
|
if (batches.length === 0) {
|
|
2863
|
-
|
|
2864
|
-
expect(iterator.done()).to.be.false;
|
|
2728
|
+
await assertIteratorIsDone(iterator);
|
|
2865
2729
|
} else {
|
|
2730
|
+
let first = true;
|
|
2866
2731
|
for (const batch of batches) {
|
|
2867
|
-
|
|
2732
|
+
first
|
|
2733
|
+
? expect(iterator.done()).to.be.undefined
|
|
2734
|
+
: expect(iterator.done()).to.be.false;
|
|
2735
|
+
first = false;
|
|
2868
2736
|
const next = await iterator.next(batch.length);
|
|
2869
|
-
expect(
|
|
2870
|
-
|
|
2871
|
-
)
|
|
2737
|
+
expect(next.map((x) => Number(x.value.number))).to.deep.equal(
|
|
2738
|
+
batch.map((x) => Number(x)),
|
|
2739
|
+
);
|
|
2872
2740
|
}
|
|
2873
|
-
|
|
2741
|
+
await assertIteratorIsDone(iterator);
|
|
2874
2742
|
}
|
|
2875
2743
|
});
|
|
2876
2744
|
};
|
|
@@ -2901,38 +2769,24 @@ export const tests = (
|
|
|
2901
2769
|
await put(1);
|
|
2902
2770
|
await put(2);
|
|
2903
2771
|
{
|
|
2904
|
-
const iterator =
|
|
2905
|
-
|
|
2906
|
-
new
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
}),
|
|
2910
|
-
);
|
|
2911
|
-
expect(iterator.done()).to.be.false;
|
|
2772
|
+
const iterator = store.iterate({
|
|
2773
|
+
query: [],
|
|
2774
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
2775
|
+
});
|
|
2776
|
+
expect(iterator.done()).to.be.undefined;
|
|
2912
2777
|
const next = await iterator.next(3);
|
|
2913
|
-
expect(next.
|
|
2914
|
-
|
|
2915
|
-
"1",
|
|
2916
|
-
"2",
|
|
2917
|
-
]);
|
|
2918
|
-
expect(iterator.done()).to.be.true;
|
|
2778
|
+
expect(next.map((x) => x.value.name)).to.deep.equal(["0", "1", "2"]);
|
|
2779
|
+
await assertIteratorIsDone(iterator);
|
|
2919
2780
|
}
|
|
2920
2781
|
{
|
|
2921
|
-
const iterator =
|
|
2922
|
-
|
|
2923
|
-
new
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
}),
|
|
2927
|
-
);
|
|
2928
|
-
expect(iterator.done()).to.be.false;
|
|
2782
|
+
const iterator = store.iterate({
|
|
2783
|
+
query: [],
|
|
2784
|
+
sort: [new Sort({ direction: SortDirection.DESC, key: "name" })],
|
|
2785
|
+
});
|
|
2786
|
+
expect(iterator.done()).to.be.undefined;
|
|
2929
2787
|
const next = await iterator.next(3);
|
|
2930
|
-
expect(next.
|
|
2931
|
-
|
|
2932
|
-
"1",
|
|
2933
|
-
"0",
|
|
2934
|
-
]);
|
|
2935
|
-
expect(iterator.done()).to.be.true;
|
|
2788
|
+
expect(next.map((x) => x.value.name)).to.deep.equal(["2", "1", "0"]);
|
|
2789
|
+
await assertIteratorIsDone(iterator);
|
|
2936
2790
|
}
|
|
2937
2791
|
});
|
|
2938
2792
|
|
|
@@ -2941,21 +2795,14 @@ export const tests = (
|
|
|
2941
2795
|
await put(1);
|
|
2942
2796
|
await put(2);
|
|
2943
2797
|
|
|
2944
|
-
const iterator = await iterate(
|
|
2945
|
-
|
|
2946
|
-
new
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
}),
|
|
2950
|
-
);
|
|
2951
|
-
expect(iterator.done()).to.be.false;
|
|
2798
|
+
const iterator = await store.iterate({
|
|
2799
|
+
query: [],
|
|
2800
|
+
sort: [new Sort({ direction: SortDirection.ASC, key: "name" })],
|
|
2801
|
+
});
|
|
2802
|
+
expect(iterator.done()).to.be.undefined;
|
|
2952
2803
|
const next = await iterator.next(3);
|
|
2953
|
-
expect(next.
|
|
2954
|
-
|
|
2955
|
-
"1",
|
|
2956
|
-
"2",
|
|
2957
|
-
]);
|
|
2958
|
-
expect(iterator.done()).to.be.true;
|
|
2804
|
+
expect(next.map((x) => x.value.name)).to.deep.equal(["0", "1", "2"]);
|
|
2805
|
+
await assertIteratorIsDone(iterator);
|
|
2959
2806
|
});
|
|
2960
2807
|
|
|
2961
2808
|
describe("nested", () => {
|
|
@@ -2971,20 +2818,18 @@ export const tests = (
|
|
|
2971
2818
|
await store.put(doc1);
|
|
2972
2819
|
await store.put(doc2);
|
|
2973
2820
|
|
|
2974
|
-
const iterator = iterate(
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
}),
|
|
2984
|
-
);
|
|
2985
|
-
expect(iterator.done()).to.be.false;
|
|
2821
|
+
const iterator = store.iterate({
|
|
2822
|
+
sort: [
|
|
2823
|
+
new Sort({
|
|
2824
|
+
direction: SortDirection.DESC,
|
|
2825
|
+
key: ["nested", "number"],
|
|
2826
|
+
}),
|
|
2827
|
+
],
|
|
2828
|
+
});
|
|
2829
|
+
expect(iterator.done()).to.be.undefined;
|
|
2986
2830
|
const next = await iterator.next(2);
|
|
2987
|
-
expect(next.
|
|
2831
|
+
expect(next.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
|
|
2832
|
+
await assertIteratorIsDone(iterator);
|
|
2988
2833
|
});
|
|
2989
2834
|
|
|
2990
2835
|
describe("nested-nested-invariant", () => {
|
|
@@ -3029,23 +2874,18 @@ export const tests = (
|
|
|
3029
2874
|
});
|
|
3030
2875
|
|
|
3031
2876
|
it("nested-variants", async () => {
|
|
3032
|
-
const iterator = iterate(
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
}),
|
|
3042
|
-
);
|
|
3043
|
-
expect(iterator.done()).to.be.false;
|
|
2877
|
+
const iterator = store.iterate({
|
|
2878
|
+
sort: [
|
|
2879
|
+
new Sort({
|
|
2880
|
+
direction: SortDirection.DESC,
|
|
2881
|
+
key: ["nested", "v0", "number"],
|
|
2882
|
+
}),
|
|
2883
|
+
],
|
|
2884
|
+
});
|
|
2885
|
+
expect(iterator.done()).to.be.undefined;
|
|
3044
2886
|
const next = await iterator.next(2);
|
|
3045
|
-
expect(next.
|
|
3046
|
-
|
|
3047
|
-
"1",
|
|
3048
|
-
]);
|
|
2887
|
+
expect(next.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
|
|
2888
|
+
await assertIteratorIsDone(iterator);
|
|
3049
2889
|
});
|
|
3050
2890
|
});
|
|
3051
2891
|
|
|
@@ -3092,82 +2932,76 @@ export const tests = (
|
|
|
3092
2932
|
});
|
|
3093
2933
|
|
|
3094
2934
|
it("nested-variants", async () => {
|
|
3095
|
-
const iterator = iterate(
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
}),
|
|
3105
|
-
);
|
|
3106
|
-
expect(iterator.done()).to.be.false;
|
|
2935
|
+
const iterator = store.iterate({
|
|
2936
|
+
sort: [
|
|
2937
|
+
new Sort({
|
|
2938
|
+
direction: SortDirection.DESC,
|
|
2939
|
+
key: ["nested", "v0", "number"],
|
|
2940
|
+
}),
|
|
2941
|
+
],
|
|
2942
|
+
});
|
|
2943
|
+
expect(iterator.done()).to.be.undefined;
|
|
3107
2944
|
const next = await iterator.next(2);
|
|
3108
|
-
expect(next.
|
|
3109
|
-
"2",
|
|
3110
|
-
"1",
|
|
3111
|
-
]);
|
|
2945
|
+
expect(next.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
|
|
3112
2946
|
});
|
|
3113
2947
|
});
|
|
3114
2948
|
/* TODO (requires sort join interleaving)
|
|
3115
2949
|
|
|
3116
2950
|
describe("nested-nested-variant", () => {
|
|
3117
|
-
|
|
2951
|
+
|
|
3118
2952
|
abstract class Base { }
|
|
3119
|
-
|
|
2953
|
+
|
|
3120
2954
|
@variant(0)
|
|
3121
2955
|
class V0 extends Base {
|
|
3122
|
-
|
|
2956
|
+
|
|
3123
2957
|
@field({ type: 'u64' })
|
|
3124
2958
|
number: bigint;
|
|
3125
|
-
|
|
2959
|
+
|
|
3126
2960
|
constructor(number: bigint) {
|
|
3127
2961
|
super()
|
|
3128
2962
|
this.number = number;
|
|
3129
2963
|
}
|
|
3130
2964
|
}
|
|
3131
|
-
|
|
2965
|
+
|
|
3132
2966
|
@variant(1)
|
|
3133
2967
|
class V1 extends Base {
|
|
3134
|
-
|
|
2968
|
+
|
|
3135
2969
|
@field({ type: 'u64' })
|
|
3136
2970
|
number: bigint;
|
|
3137
|
-
|
|
2971
|
+
|
|
3138
2972
|
constructor(number: bigint) {
|
|
3139
2973
|
super()
|
|
3140
2974
|
this.number = number;
|
|
3141
2975
|
}
|
|
3142
2976
|
}
|
|
3143
|
-
|
|
2977
|
+
|
|
3144
2978
|
class NestedValue {
|
|
3145
2979
|
@field({ type: Base })
|
|
3146
2980
|
v0: Base;
|
|
3147
|
-
|
|
2981
|
+
|
|
3148
2982
|
constructor(v0?: Base) {
|
|
3149
2983
|
this.v0 = v0;
|
|
3150
2984
|
}
|
|
3151
2985
|
}
|
|
3152
|
-
|
|
2986
|
+
|
|
3153
2987
|
class Document {
|
|
3154
2988
|
@id({ type: 'string' })
|
|
3155
2989
|
id: string;
|
|
3156
|
-
|
|
2990
|
+
|
|
3157
2991
|
@field({ type: NestedValue })
|
|
3158
2992
|
nested: NestedValue;
|
|
3159
|
-
|
|
2993
|
+
|
|
3160
2994
|
constructor(id: string, nested: NestedValue) {
|
|
3161
2995
|
this.id = id;
|
|
3162
2996
|
this.nested = nested;
|
|
3163
2997
|
}
|
|
3164
2998
|
}
|
|
3165
|
-
|
|
2999
|
+
|
|
3166
3000
|
const doc1 = new Document("1", new NestedValue(new V0(1n)));
|
|
3167
3001
|
const doc2 = new Document("2", new NestedValue(new V0(2n)));
|
|
3168
3002
|
const doc3 = new Document("3", new NestedValue(new V1(3n)));
|
|
3169
3003
|
const doc4 = new Document("4", new NestedValue(new V1(4n)));
|
|
3170
|
-
|
|
3004
|
+
|
|
3171
3005
|
beforeEach(async () => {
|
|
3172
3006
|
await setup({ schema: Document });
|
|
3173
3007
|
await store.put(doc1);
|
|
@@ -3175,15 +3009,15 @@ export const tests = (
|
|
|
3175
3009
|
await store.put(doc3);
|
|
3176
3010
|
await store.put(doc4);
|
|
3177
3011
|
});
|
|
3178
|
-
|
|
3012
|
+
|
|
3179
3013
|
it("nested-variants", async () => {
|
|
3180
|
-
const iterator = iterate(store,
|
|
3014
|
+
const iterator = iterate(store, ({ sort: [new Sort({ direction: SortDirection.DESC, key: ["nested", "v0", "number"] })] }));
|
|
3181
3015
|
expect(iterator.done()).to.be.false;
|
|
3182
3016
|
const next = await iterator.next(4);
|
|
3183
3017
|
expect(next.results.map((x) => x.value.id)).to.deep.equal(["4", "3", "2", "1"]);
|
|
3184
|
-
|
|
3018
|
+
|
|
3185
3019
|
})
|
|
3186
|
-
|
|
3020
|
+
|
|
3187
3021
|
})*/
|
|
3188
3022
|
|
|
3189
3023
|
/* TODO
|
|
@@ -3210,7 +3044,7 @@ export const tests = (
|
|
|
3210
3044
|
await store.put(doc2);
|
|
3211
3045
|
await store.put(doc3);
|
|
3212
3046
|
|
|
3213
|
-
const iterator = iterate(store,
|
|
3047
|
+
const iterator = iterate(store, ({ query: [new IntegerCompare({ key: 'number', compare: 'gte', value: 102n }), new Nested({ path: 'nestedVec', id: 'path-to-nested', query: [new IntegerCompare({ key: 'number', compare: 'gte', value: 200 })] })], sort: [new Sort({ direction: SortDirection.DESC, key: ["path-to-nested", "number"] })] }));
|
|
3214
3048
|
expect(iterator.done()).to.be.false;
|
|
3215
3049
|
const next = await iterator.next(2);
|
|
3216
3050
|
expect(next.results.map((x) => x.value.id)).to.deep.equal(["2", "1"]);
|
|
@@ -3223,51 +3057,45 @@ export const tests = (
|
|
|
3223
3057
|
await put(0);
|
|
3224
3058
|
await put(1);
|
|
3225
3059
|
await put(2);
|
|
3226
|
-
const request =
|
|
3060
|
+
const request = {
|
|
3227
3061
|
query: [],
|
|
3228
|
-
}
|
|
3229
|
-
const iterator = iterate(
|
|
3230
|
-
expect(iterator.done()).to.be.
|
|
3062
|
+
};
|
|
3063
|
+
const iterator = store.iterate(request);
|
|
3064
|
+
expect(iterator.done()).to.be.undefined;
|
|
3231
3065
|
await iterator.next(2); // fetch some, but not all
|
|
3232
|
-
expect(
|
|
3066
|
+
expect(iterator.done()).to.be.false;
|
|
3067
|
+
expect(await iterator.pending()).equal(1);
|
|
3233
3068
|
await iterator.close();
|
|
3234
|
-
await
|
|
3235
|
-
|
|
3236
|
-
{ timeout: 3000, delayInterval: 50 },
|
|
3237
|
-
);
|
|
3069
|
+
expect(await iterator.pending()).equal(0);
|
|
3070
|
+
expect(iterator.done()).to.be.true;
|
|
3238
3071
|
});
|
|
3239
3072
|
|
|
3240
3073
|
it("end of iterator", async () => {
|
|
3241
3074
|
await put(0);
|
|
3242
3075
|
await put(1);
|
|
3243
3076
|
await put(2);
|
|
3244
|
-
const request =
|
|
3077
|
+
const request = {
|
|
3245
3078
|
query: [],
|
|
3246
|
-
}
|
|
3247
|
-
const iterator =
|
|
3248
|
-
expect(iterator.done()).to.be.
|
|
3079
|
+
};
|
|
3080
|
+
const iterator = store.iterate(request);
|
|
3081
|
+
expect(iterator.done()).to.be.undefined;
|
|
3249
3082
|
await iterator.next(3); // fetch all
|
|
3250
|
-
await
|
|
3251
|
-
|
|
3252
|
-
{ timeout: 3000, delayInterval: 50 },
|
|
3253
|
-
);
|
|
3083
|
+
expect(await iterator.pending()).equal(0);
|
|
3084
|
+
expect(iterator.done()).to.be.true;
|
|
3254
3085
|
});
|
|
3255
3086
|
|
|
3256
3087
|
it("end of iterator, multiple nexts", async () => {
|
|
3257
3088
|
await put(0);
|
|
3258
3089
|
await put(1);
|
|
3259
3090
|
await put(2);
|
|
3260
|
-
const request =
|
|
3091
|
+
const request = {
|
|
3261
3092
|
query: [],
|
|
3262
|
-
}
|
|
3263
|
-
const iterator =
|
|
3093
|
+
};
|
|
3094
|
+
const iterator = store.iterate(request);
|
|
3264
3095
|
await iterator.next(2);
|
|
3265
3096
|
await iterator.next(1);
|
|
3266
|
-
|
|
3267
|
-
await
|
|
3268
|
-
() => expect(store.getPending(request.idString)).equal(undefined),
|
|
3269
|
-
{ timeout: 3000, delayInterval: 50 },
|
|
3270
|
-
);
|
|
3097
|
+
assertIteratorIsDone(iterator);
|
|
3098
|
+
expect(await iterator.pending()).equal(0);
|
|
3271
3099
|
});
|
|
3272
3100
|
});
|
|
3273
3101
|
|
|
@@ -3281,7 +3109,7 @@ export const tests = (
|
|
|
3281
3109
|
describe("sum", () => {
|
|
3282
3110
|
it("it returns sum", async () => {
|
|
3283
3111
|
await setupDefault();
|
|
3284
|
-
const sum = await store.sum(
|
|
3112
|
+
const sum = await store.sum({ key: "number" });
|
|
3285
3113
|
typeof sum === "bigint"
|
|
3286
3114
|
? expect(sum).to.equal(6n)
|
|
3287
3115
|
: expect(sum).to.equal(6);
|
|
@@ -3289,19 +3117,17 @@ export const tests = (
|
|
|
3289
3117
|
|
|
3290
3118
|
it("it returns sum with query", async () => {
|
|
3291
3119
|
await setupDefault();
|
|
3292
|
-
const sum = await store.sum(
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
}),
|
|
3304
|
-
);
|
|
3120
|
+
const sum = await store.sum({
|
|
3121
|
+
key: "number",
|
|
3122
|
+
query: [
|
|
3123
|
+
new StringMatch({
|
|
3124
|
+
key: "tags",
|
|
3125
|
+
value: "world",
|
|
3126
|
+
method: StringMatchMethod.contains,
|
|
3127
|
+
caseInsensitive: true,
|
|
3128
|
+
}),
|
|
3129
|
+
],
|
|
3130
|
+
});
|
|
3305
3131
|
typeof sum === "bigint"
|
|
3306
3132
|
? expect(sum).to.equal(2n)
|
|
3307
3133
|
: expect(sum).to.equal(2);
|
|
@@ -3328,11 +3154,9 @@ export const tests = (
|
|
|
3328
3154
|
await store.put(doc2);
|
|
3329
3155
|
await store.put(doc3);
|
|
3330
3156
|
|
|
3331
|
-
const sum = await store.sum(
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
}),
|
|
3335
|
-
);
|
|
3157
|
+
const sum = await store.sum({
|
|
3158
|
+
key: ["nested", "number"],
|
|
3159
|
+
});
|
|
3336
3160
|
|
|
3337
3161
|
typeof sum === "bigint"
|
|
3338
3162
|
? expect(sum).to.equal(3n)
|
|
@@ -3343,24 +3167,22 @@ export const tests = (
|
|
|
3343
3167
|
describe("count", () => {
|
|
3344
3168
|
it("it returns count", async () => {
|
|
3345
3169
|
await setupDefault();
|
|
3346
|
-
const sum = await store.count(
|
|
3170
|
+
const sum = await store.count();
|
|
3347
3171
|
expect(sum).to.equal(4);
|
|
3348
3172
|
});
|
|
3349
3173
|
|
|
3350
3174
|
it("it returns count with query", async () => {
|
|
3351
3175
|
await setupDefault();
|
|
3352
|
-
const sum = await store.count(
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
}),
|
|
3363
|
-
);
|
|
3176
|
+
const sum = await store.count({
|
|
3177
|
+
query: [
|
|
3178
|
+
new StringMatch({
|
|
3179
|
+
key: "tags",
|
|
3180
|
+
value: "world",
|
|
3181
|
+
method: StringMatchMethod.contains,
|
|
3182
|
+
caseInsensitive: true,
|
|
3183
|
+
}),
|
|
3184
|
+
],
|
|
3185
|
+
});
|
|
3364
3186
|
expect(sum).to.equal(1);
|
|
3365
3187
|
});
|
|
3366
3188
|
});
|
|
@@ -3368,18 +3190,16 @@ export const tests = (
|
|
|
3368
3190
|
describe("delete", () => {
|
|
3369
3191
|
it("delete with query", async () => {
|
|
3370
3192
|
await setupDefault();
|
|
3371
|
-
await store.del(
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
}),
|
|
3382
|
-
);
|
|
3193
|
+
await store.del({
|
|
3194
|
+
query: [
|
|
3195
|
+
new StringMatch({
|
|
3196
|
+
key: "tags",
|
|
3197
|
+
value: "world",
|
|
3198
|
+
method: StringMatchMethod.contains,
|
|
3199
|
+
caseInsensitive: true,
|
|
3200
|
+
}),
|
|
3201
|
+
],
|
|
3202
|
+
});
|
|
3383
3203
|
expect(await store.getSize()).to.equal(3);
|
|
3384
3204
|
});
|
|
3385
3205
|
});
|
|
@@ -3415,7 +3235,7 @@ export const tests = (
|
|
|
3415
3235
|
for (let i = 0; i < 100; i++) {
|
|
3416
3236
|
promises.push(
|
|
3417
3237
|
(async () => {
|
|
3418
|
-
results.push(await store.count(
|
|
3238
|
+
results.push(await store.count());
|
|
3419
3239
|
})(),
|
|
3420
3240
|
);
|
|
3421
3241
|
}
|
|
@@ -3598,14 +3418,10 @@ export const tests = (
|
|
|
3598
3418
|
await aIndex.put(
|
|
3599
3419
|
new Document({ id: "a", name: "hello", number: 1n, tags: [] }),
|
|
3600
3420
|
);
|
|
3601
|
-
expect(
|
|
3602
|
-
await aIndex.count(new CountRequest({ query: { id: "a" } })),
|
|
3603
|
-
).to.eq(1);
|
|
3421
|
+
expect(await aIndex.count({ query: { id: "a" } })).to.eq(1);
|
|
3604
3422
|
|
|
3605
3423
|
await bIndex.put(new AnotherDocument("b"));
|
|
3606
|
-
expect(
|
|
3607
|
-
await bIndex.count(new CountRequest({ query: { id: "b" } })),
|
|
3608
|
-
).to.eq(1);
|
|
3424
|
+
expect(await bIndex.count({ query: { id: "b" } })).to.eq(1);
|
|
3609
3425
|
});
|
|
3610
3426
|
});
|
|
3611
3427
|
});
|
|
@@ -3658,7 +3474,7 @@ describe("multi-dimensional", () => {
|
|
|
3658
3474
|
promises.push(
|
|
3659
3475
|
search(
|
|
3660
3476
|
store,
|
|
3661
|
-
|
|
3477
|
+
({
|
|
3662
3478
|
query: [
|
|
3663
3479
|
new IntegerCompare({
|
|
3664
3480
|
key: "number",
|
|
@@ -3673,7 +3489,7 @@ describe("multi-dimensional", () => {
|
|
|
3673
3489
|
promises.push(
|
|
3674
3490
|
search(
|
|
3675
3491
|
store,
|
|
3676
|
-
|
|
3492
|
+
({
|
|
3677
3493
|
query: [
|
|
3678
3494
|
new IntegerCompare({
|
|
3679
3495
|
key: "number",
|