@@ -1341,7 +1341,7 @@ describe('Feathers Objection Service', () => {
13411341 . create ( [
13421342 {
13431343 name : 'Google' ,
1344- jsonObject : {
1344+ jsonbObject : {
13451345 stringField : 'string' ,
13461346 numberField : 1.5 ,
13471347 objectField : {
@@ -1356,6 +1356,24 @@ describe('Feathers Objection Service', () => {
13561356 }
13571357 }
13581358 ]
1359+ } ,
1360+ {
1361+ name : 'Apple' ,
1362+ jsonbObject : {
1363+ stringField : 'string2' ,
1364+ numberField : 1 ,
1365+ objectField : {
1366+ object : 'string in jsonObject.objectField.object2'
1367+ } ,
1368+ 'first.founder' : 'Dave'
1369+ } ,
1370+ jsonArray : [
1371+ {
1372+ objectField : {
1373+ object : 'I\'m string in jsonArray[0].objectField.object2'
1374+ }
1375+ }
1376+ ]
13591377 }
13601378 ] ) ;
13611379 } ) ;
@@ -1365,43 +1383,43 @@ describe('Feathers Objection Service', () => {
13651383 } ) ;
13661384
13671385 it ( 'object' , ( ) => {
1368- return companies . find ( { query : { jsonObject : { $ne : null } } } ) . then ( data => {
1369- expect ( data [ 0 ] . jsonObject . stringField ) . to . equal ( 'string' ) ;
1386+ return companies . find ( { query : { jsonbObject : { $ne : null } } } ) . then ( data => {
1387+ expect ( data [ 0 ] . jsonbObject . stringField ) . to . equal ( 'string' ) ;
13701388 } ) ;
13711389 } ) ;
13721390
13731391 it ( 'object stringField' , ( ) => {
1374- return companies . find ( { query : { jsonObject : { stringField : 'string' } } } ) . then ( data => {
1375- expect ( data [ 0 ] . jsonObject . stringField ) . to . equal ( 'string' ) ;
1392+ return companies . find ( { query : { jsonbObject : { stringField : 'string' } } } ) . then ( data => {
1393+ expect ( data [ 0 ] . jsonbObject . stringField ) . to . equal ( 'string' ) ;
13761394 } ) ;
13771395 } ) ;
13781396
13791397 it ( 'object stringField $like' , ( ) => {
1380- return companies . find ( { query : { jsonObject : { stringField : { $like : 'str%' } } } } ) . then ( data => {
1381- expect ( data [ 0 ] . jsonObject . stringField ) . to . equal ( 'string' ) ;
1398+ return companies . find ( { query : { jsonbObject : { stringField : { $like : 'str%' } } } } ) . then ( data => {
1399+ expect ( data [ 0 ] . jsonbObject . stringField ) . to . equal ( 'string' ) ;
13821400 } ) ;
13831401 } ) ;
13841402
13851403 it ( 'object numberField $between' , ( ) => {
1386- return companies . find ( { query : { jsonObject : { numberField : { $between : [ 1 , 2 ] } } } } ) . then ( data => {
1387- expect ( data [ 0 ] . jsonObject . stringField ) . to . equal ( 'string' ) ;
1404+ return companies . find ( { query : { jsonbObject : { numberField : { $between : [ 1 , 2 ] } } } } ) . then ( data => {
1405+ expect ( data [ 0 ] . jsonbObject . stringField ) . to . equal ( 'string' ) ;
13881406 } ) ;
13891407 } ) ;
13901408
13911409 it ( 'object numberField' , ( ) => {
1392- return companies . find ( { query : { jsonObject : { numberField : 1.5 } } } ) . then ( data => {
1393- expect ( data [ 0 ] . jsonObject . numberField ) . to . equal ( 1.5 ) ;
1410+ return companies . find ( { query : { jsonbObject : { numberField : 1.5 } } } ) . then ( data => {
1411+ expect ( data [ 0 ] . jsonbObject . numberField ) . to . equal ( 1.5 ) ;
13941412 } ) ;
13951413 } ) ;
13961414
13971415 it ( 'object numberField $gt' , ( ) => {
1398- return companies . find ( { query : { jsonObject : { numberField : { $gt : 1.4 } } } } ) . then ( data => {
1416+ return companies . find ( { query : { jsonbObject : { numberField : { $gt : 1.4 } } } } ) . then ( data => {
13991417 expect ( data [ 0 ] . jsonArray [ 0 ] . objectField . object ) . to . equal ( 'I\'m string in jsonArray[0].objectField.object' ) ;
14001418 } ) ;
14011419 } ) ;
14021420
14031421 it ( 'object nested object' , ( ) => {
1404- return companies . find ( { query : { jsonObject : { 'objectField.object' : 'string in jsonObject.objectField.object' } } } ) . then ( data => {
1422+ return companies . find ( { query : { jsonbObject : { 'objectField.object' : 'string in jsonObject.objectField.object' } } } ) . then ( data => {
14051423 expect ( data [ 0 ] . jsonArray [ 0 ] . objectField . object ) . to . equal ( 'I\'m string in jsonArray[0].objectField.object' ) ;
14061424 } ) ;
14071425 } ) ;
@@ -1419,14 +1437,28 @@ describe('Feathers Objection Service', () => {
14191437 } ) ;
14201438
14211439 it ( 'dot in property name' , ( ) => {
1422- return companies . find ( { query : { jsonObject : { '(first.founder)' : 'John' } } } ) . then ( data => {
1423- expect ( data [ 0 ] . jsonObject [ 'first.founder' ] ) . to . equal ( 'John' ) ;
1440+ return companies . find ( { query : { jsonbObject : { '(first.founder)' : 'John' } } } ) . then ( data => {
1441+ expect ( data [ 0 ] . jsonbObject [ 'first.founder' ] ) . to . equal ( 'John' ) ;
14241442 } ) ;
14251443 } ) ;
14261444
14271445 it ( 'dot in property name with brackets' , ( ) => {
1428- return companies . find ( { query : { jsonObject : { '[first.founder]' : 'John' } } } ) . then ( data => {
1429- expect ( data [ 0 ] . jsonObject [ 'first.founder' ] ) . to . equal ( 'John' ) ;
1446+ return companies . find ( { query : { jsonbObject : { '[first.founder]' : 'John' } } } ) . then ( data => {
1447+ expect ( data [ 0 ] . jsonbObject [ 'first.founder' ] ) . to . equal ( 'John' ) ;
1448+ } ) ;
1449+ } ) ;
1450+
1451+ it ( 'select & sort with ref' , ( ) => {
1452+ return companies . find ( {
1453+ query : {
1454+ $select : [ 'name' , 'ref(jsonbObject:numberField)' , 'ref(jsonbObject:objectField.object) as object' ] ,
1455+ $sort : { 'ref(jsonbObject:numberField)' : 1 }
1456+ }
1457+ } ) . then ( data => {
1458+ expect ( data . length ) . to . equal ( 2 ) ;
1459+ expect ( data [ 0 ] . name ) . to . equal ( 'Apple' ) ;
1460+ expect ( data [ 0 ] [ 'jsonbObject:numberField' ] ) . to . equal ( 1 ) ;
1461+ expect ( data [ 0 ] . object ) . to . equal ( 'string in jsonObject.objectField.object2' ) ;
14301462 } ) ;
14311463 } ) ;
14321464 } ) ;
0 commit comments