11'use strict' ;
22
3- describe ( 'test.pick-fields.js' , function ( ) {
4- it ( 'should pick shallow fields' , function ( ) {
5- var db = context . db ;
6- return db . bulkDocs ( [
3+ describe ( 'test.pick-fields.js' , ( ) => {
4+ it ( 'should pick shallow fields' , async ( ) => {
5+ const db = context . db ;
6+ await db . bulkDocs ( [
77 { name : 'Mario' , _id : 'mario' , series : 'Mario' , debut : { year : 1981 , month : 'May' } } ,
88 { name : 'Jigglypuff' , _id : 'puff' , series : 'Pokemon' , debut : { year : 1996 , month : 'June' } } ,
99 { name : 'Link' , _id : 'link' , series : 'Zelda' , debut : { year : 1986 , month : 'July' } } ,
@@ -12,58 +12,52 @@ describe('test.pick-fields.js', function () {
1212 debut : { year : 1996 , month : 'September' } } ,
1313 { name : 'Captain Falcon' , _id : 'falcon' , series : 'F-Zero' ,
1414 debut : { year : 1990 , month : 'December' } }
15- ] ) . then ( function ( ) {
16- return db . find ( {
17- selector : { _id : { $gt : null } } ,
18- sort : [ '_id' ] ,
19- fields : [ 'name' ]
20- } ) ;
21- } ) . then ( function ( res ) {
22- res . docs . should . deep . equal ( [
23- { name : 'Donkey Kong' } ,
24- { name : 'Captain Falcon' } ,
25- { name : 'Link' } ,
26- { name : 'Mario' } ,
27- { name : 'Pikachu' } ,
28- { name : 'Jigglypuff' } ] ) ;
15+ ] ) ;
16+ const res = await db . find ( {
17+ selector : { _id : { $gt : null } } ,
18+ sort : [ '_id' ] ,
19+ fields : [ 'name' ]
2920 } ) ;
21+ res . docs . should . deep . equal ( [
22+ { name : 'Donkey Kong' } ,
23+ { name : 'Captain Falcon' } ,
24+ { name : 'Link' } ,
25+ { name : 'Mario' } ,
26+ { name : 'Pikachu' } ,
27+ { name : 'Jigglypuff' } ] ) ;
3028 } ) ;
3129
32- it ( 'should pick deep fields' , function ( ) {
33- var db = context . db ;
34- return db . bulkDocs ( [
30+ it ( 'should pick deep fields' , async ( ) => {
31+ const db = context . db ;
32+ await db . bulkDocs ( [
3533 { _id : 'a' , foo : { bar : 'yo' } , bar : { baz : 'hey' } } ,
3634 { _id : 'b' , foo : { bar : 'sup' } , bar : { baz : 'dawg' } } ,
3735 { _id : 'c' , foo : true , bar : "yo" } ,
3836 { _id : 'd' , foo : null , bar : [ ] }
39- ] ) . then ( function ( ) {
40- return db . find ( {
41- selector : { _id : { $gt : null } } ,
42- sort : [ '_id' ] ,
43- fields : [ '_id' , 'bar.baz' ]
44- } ) ;
45- } ) . then ( function ( res ) {
46- res . docs . should . deep . equal ( [
47- { _id : 'a' , bar : { baz : 'hey' } } ,
48- { _id : 'b' , bar : { baz : 'dawg' } } ,
49- { _id : 'c' } ,
50- { _id : 'd' } ] ) ;
37+ ] ) ;
38+ const res = await db . find ( {
39+ selector : { _id : { $gt : null } } ,
40+ sort : [ '_id' ] ,
41+ fields : [ '_id' , 'bar.baz' ]
5142 } ) ;
43+ res . docs . should . deep . equal ( [
44+ { _id : 'a' , bar : { baz : 'hey' } } ,
45+ { _id : 'b' , bar : { baz : 'dawg' } } ,
46+ { _id : 'c' } ,
47+ { _id : 'd' } ] ) ;
5248 } ) ;
5349
54- it ( 'should pick really deep fields with escape' , function ( ) {
55- var db = context . db ;
56- return db . bulkDocs ( [
50+ it ( 'should pick really deep fields with escape' , async ( ) => {
51+ const db = context . db ;
52+ await db . bulkDocs ( [
5753 { _id : 'a' , really : { deeply : { nested : { 'escaped.field' : 'You found me!' } } } }
58- ] ) . then ( function ( ) {
59- return db . find ( {
60- selector : { _id : { $gt : null } } ,
61- fields : [ 'really.deeply.nested.escaped\\.field' ]
62- } ) ;
63- } ) . then ( function ( res ) {
64- res . docs . should . deep . equal ( [
65- { really : { deeply : { nested : { 'escaped.field' : 'You found me!' } } } }
66- ] ) ;
54+ ] ) ;
55+ const res = await db . find ( {
56+ selector : { _id : { $gt : null } } ,
57+ fields : [ 'really.deeply.nested.escaped\\.field' ]
6758 } ) ;
59+ res . docs . should . deep . equal ( [
60+ { really : { deeply : { nested : { 'escaped.field' : 'You found me!' } } } }
61+ ] ) ;
6862 } ) ;
6963} ) ;
0 commit comments