@@ -90,12 +90,37 @@ describe('NoSQLax Testing Suite', () => {
9090 constructor ( connection , options = { } ) {
9191 super ( connection , options , TestEntity ) ;
9292 }
93+
94+ async findOrFailByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
95+ return await this . findOne ( { name : { $eq : name } , age : { $gte : age } , city : { $eq : city } } )
96+ }
97+
98+ async getAllByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
99+ return await this . findMany ( { "$and" : [ { "$or" : [ { name : { $eq : name } } ] } , { "$not" : { age : { $lt : age } } } ] , city : { $beginsWith : city } } )
100+ }
101+
102+ async getViewA ( options ) {
103+ return this . dbConnection . view ( 'design' , 'view' , options )
104+ }
105+
93106 }
94107
95108 class TestRepositorySchemaId extends CouchRepository {
96109 constructor ( connection , options = { } ) {
97110 super ( connection , options , TestEntitySchemaId ) ;
98111 }
112+
113+ async findOrFailByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
114+ return await this . findOne ( { name : { $eq : name } , age : { $gte : age } , city : { $eq : city } } )
115+ }
116+
117+ async getAllByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
118+ return await this . findMany ( { "$and" : [ { "$or" : [ { name : { $eq : name } } ] } , { "$not" : { age : { $lt : age } } } ] , city : { $beginsWith : city } } )
119+ }
120+
121+ async getViewA ( options ) {
122+ return this . dbConnection . view ( 'design' , 'view' , options )
123+ }
99124 }
100125
101126
@@ -121,16 +146,16 @@ describe('NoSQLax Testing Suite', () => {
121146 return await this . testRepository . find ( id )
122147 }
123148
124- async getByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
125- return await this . testRepository . findMany ( { "$and" : [ { "$or" : [ { name : { $eq : name } } ] } , { "$not" : { age : { $lt : age } } } ] , city : { $beginsWith : city } } )
149+ async getAllByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
150+ return await this . testRepository . getAllByAgeGreaterThanAndbByNameAndByCity ( age , name , city )
126151 }
127152
128153 async findOneOrFailById ( id ) {
129154 return await this . testRepository . find ( id )
130155 }
131156
132157 async findOrFailByAgeGreaterThanAndbByNameAndByCity ( age , name , city ) {
133- return await this . testRepository . findOne ( { name : { $eq : name } , age : { $gte : age } , city : { $eq : city } } )
158+ return await this . testRepository . findOrFailByAgeGreaterThanAndbByNameAndByCity ( age , name , city )
134159 }
135160
136161 async update ( id , entity ) {
@@ -144,7 +169,7 @@ describe('NoSQLax Testing Suite', () => {
144169 }
145170
146171 async getViewA ( options ) {
147- return testRepository . dbConnection . view ( 'design' , 'view' , options )
172+ return testRepository . getViewA ( options ) ;
148173 }
149174
150175 async findAll ( ) {
@@ -266,7 +291,7 @@ describe('NoSQLax Testing Suite', () => {
266291 const mockDoc = { _id : '12345' , _rev : '1-abc' , name_field : 'John Doe' , age : 30 , city : 'Lyon' } ;
267292 mockConnection . find . mockResolvedValue ( { docs : [ mockDoc ] } ) ;
268293
269- const entities = await testService . getByAgeGreaterThanAndbByNameAndByCity ( 18 , 'John Doe' , 'Lyon' )
294+ const entities = await testService . getAllByAgeGreaterThanAndbByNameAndByCity ( 18 , 'John Doe' , 'Lyon' )
270295
271296 expect ( mockConnection . find ) . toHaveBeenCalledWith (
272297 expect . objectContaining ( {
0 commit comments