@@ -4,6 +4,7 @@ const { getMockLMDBPath } = require('../test_utils');
44const { parseQuery } = require ( '#src/resources/search' ) ;
55const { table } = require ( '#src/resources/databases' ) ;
66const { transaction } = require ( '#src/resources/transaction' ) ;
7+ const { RequestTarget } = require ( '#src/resources/RequestTarget' ) ;
78const { setMainIsWorker } = require ( '#js/server/threads/manageThreads' ) ;
89let x = 532532 ;
910function random ( max ) {
@@ -1368,7 +1369,7 @@ describe('Querying through Resource API', () => {
13681369 } ) ;
13691370 it ( 'Parsed query data in a table and select with special properties and star' , async function ( ) {
13701371 let results = [ ] ;
1371- for await ( let record of QueryTable . search ( { url : '?id=ge=id-90&select($id,$updatedtime,*)' } ) ) {
1372+ for await ( let record of QueryTable . search ( new RequestTarget ( '?id=ge=id-90&select($id,$updatedtime,*)' ) ) ) {
13721373 results . push ( record ) ;
13731374 }
13741375
@@ -1383,7 +1384,9 @@ describe('Querying through Resource API', () => {
13831384
13841385 it ( 'Parsed nested query data in a table' , async function ( ) {
13851386 let results = [ ] ;
1386- for await ( let record of QueryTable . search ( { url : '?(id=ge=id-90&id=le=id-93)|(name=name-95&id=ge=id-94)' } ) ) {
1387+ for await ( let record of QueryTable . search (
1388+ new RequestTarget ( '?(id=ge=id-90&id=le=id-93)|(name=name-95&id=ge=id-94)' )
1389+ ) ) {
13871390 results . push ( record ) ;
13881391 }
13891392 assert . equal ( results . length , 5 ) ;
@@ -1392,7 +1395,9 @@ describe('Querying through Resource API', () => {
13921395 } ) ;
13931396 it ( 'Parsed nested query data in a table with brackets' , async function ( ) {
13941397 let results = [ ] ;
1395- for await ( let record of QueryTable . search ( { url : '?[id=ge=id-90&id=le=id-93]|[name=name-95&id=ge=id-94]' } ) ) {
1398+ for await ( let record of QueryTable . search (
1399+ new RequestTarget ( '?[id=ge=id-90&id=le=id-93]|[name=name-95&id=ge=id-94]' )
1400+ ) ) {
13961401 results . push ( record ) ;
13971402 }
13981403 assert . equal ( results . length , 5 ) ;
@@ -1401,9 +1406,9 @@ describe('Querying through Resource API', () => {
14011406 } ) ;
14021407 it ( 'Parsed nested query data in a table with joined sort' , async function ( ) {
14031408 let results = [ ] ;
1404- for await ( let record of QueryTable . search ( {
1405- url : '?(id>id-80&id<=id-93)|(name=name-95&id>id-94)&sort(-related.name)' ,
1406- } ) ) {
1409+ for await ( let record of QueryTable . search (
1410+ new RequestTarget ( '?(id>id-80&id<=id-93)|(name=name-95&id>id-94)&sort(-related.name)' )
1411+ ) ) {
14071412 results . push ( record ) ;
14081413 }
14091414 assert . equal ( results . length , 15 ) ;
@@ -1413,9 +1418,9 @@ describe('Querying through Resource API', () => {
14131418 } ) ;
14141419 it ( 'Parsed query data in a table with one-to-many joined sort that is not primary' , async function ( ) {
14151420 let results = [ ] ;
1416- for await ( let record of RelatedTable . search ( {
1417- url : '?name=related name 3&sort(-relatedToMany.name)&select(id,relatedToMany)' ,
1418- } ) ) {
1421+ for await ( let record of RelatedTable . search (
1422+ new RequestTarget ( '?name=related name 3&sort(-relatedToMany.name)&select(id,relatedToMany)' )
1423+ ) ) {
14191424 results . push ( record ) ;
14201425 }
14211426 assert . equal ( results . length , 1 ) ;
@@ -1426,9 +1431,9 @@ describe('Querying through Resource API', () => {
14261431 } ) ;
14271432 it ( 'Parsed query data in a table with many-to-many joined sort that is not primary' , async function ( ) {
14281433 let results = [ ] ;
1429- for await ( let record of QueryTable . search ( {
1430- url : '?id=id-14&sort(-manyToMany.name)&select(id,manyToMany)' ,
1431- } ) ) {
1434+ for await ( let record of QueryTable . search (
1435+ new RequestTarget ( '?id=id-14&sort(-manyToMany.name)&select(id,manyToMany)' )
1436+ ) ) {
14321437 results . push ( record ) ;
14331438 }
14341439 assert . equal ( results . length , 1 ) ;
@@ -1439,9 +1444,9 @@ describe('Querying through Resource API', () => {
14391444 } ) ;
14401445 it ( 'Parsed query data in a table with many-to-many joined sort that has missing entries and multiple sorts' , async function ( ) {
14411446 let results = [ ] ;
1442- for await ( let record of QueryTable . search ( {
1443- url : '?id=id-12|id=id-24&sort(-id,-manyToMany.name)&select(id,manyToMany,manyToManyIds)' ,
1444- } ) ) {
1447+ for await ( let record of QueryTable . search (
1448+ new RequestTarget ( '?id=id-12|id=id-24&sort(-id,-manyToMany.name)&select(id,manyToMany,manyToManyIds)' )
1449+ ) ) {
14451450 results . push ( record ) ;
14461451 }
14471452 assert . equal ( results . length , 2 ) ;
@@ -1455,9 +1460,7 @@ describe('Querying through Resource API', () => {
14551460
14561461 it ( 'Parsed query data in a table with not equal to null' , async function ( ) {
14571462 let results = [ ] ;
1458- for await ( let record of QueryTable . search ( {
1459- url : '?sparse!=null' ,
1460- } ) ) {
1463+ for await ( let record of QueryTable . search ( new RequestTarget ( '?sparse!=null' ) ) ) {
14611464 results . push ( record ) ;
14621465 }
14631466 assert . equal ( results . length , 17 ) ;
@@ -1467,9 +1470,7 @@ describe('Querying through Resource API', () => {
14671470 } ) ;
14681471 it ( 'Parsed query with boolean equal to true' , async function ( ) {
14691472 let results = [ ] ;
1470- for await ( let record of RelatedTable . search ( {
1471- url : '?aFlag==true' ,
1472- } ) ) {
1473+ for await ( let record of RelatedTable . search ( new RequestTarget ( '?aFlag==true' ) ) ) {
14731474 results . push ( record ) ;
14741475 }
14751476 assert . equal ( results . length , 2 ) ;
@@ -1479,9 +1480,7 @@ describe('Querying through Resource API', () => {
14791480 } ) ;
14801481 it ( 'Parsed query with boolean equal to false' , async function ( ) {
14811482 let results = [ ] ;
1482- for await ( let record of RelatedTable . search ( {
1483- url : '?aFlag==false' ,
1484- } ) ) {
1483+ for await ( let record of RelatedTable . search ( new RequestTarget ( '?aFlag==false' ) ) ) {
14851484 results . push ( record ) ;
14861485 }
14871486 assert . equal ( results . length , 3 ) ;
@@ -1494,12 +1493,7 @@ describe('Querying through Resource API', () => {
14941493 let context = { } ;
14951494 await RelatedTable . get ( 1 , context ) ; // This will set the lastModified on the context
14961495 assert ( isFinite ( context . lastModified ) ) ;
1497- for await ( let record of RelatedTable . search (
1498- {
1499- url : '?aFlag==true' ,
1500- } ,
1501- context
1502- ) ) {
1496+ for await ( let record of RelatedTable . search ( new RequestTarget ( '?aFlag==true' ) , context ) ) {
15031497 results . push ( record ) ;
15041498 }
15051499 assert ( ! isFinite ( context . lastModified ) ) ;
0 commit comments