fix: operator query value (#216)
* fix: operator query value * fix: operator query value
This commit is contained in:
		
							parent
							
								
									78ada4d6ec
								
							
						
					
					
						commit
						b354313c0e
					
				@ -39,4 +39,24 @@ describe('string operator', () => {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    expect(u1Res.get('id')).toEqual(u1.get('id'));
 | 
					    expect(u1Res.get('id')).toEqual(u1.get('id'));
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  it('should query with and ', async () => {
 | 
				
			||||||
 | 
					    const u1 = await db.getRepository('users').create({
 | 
				
			||||||
 | 
					      values: {
 | 
				
			||||||
 | 
					        name: 'names of u1',
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const u1Res = await db.getRepository('users').findOne({
 | 
				
			||||||
 | 
					      filter: {
 | 
				
			||||||
 | 
					        $and: [
 | 
				
			||||||
 | 
					          {
 | 
				
			||||||
 | 
					            'name.$includes': 'u1',
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					        ],
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expect(u1Res.get('id')).toEqual(u1.get('id'));
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
import { flatten } from 'flat';
 | 
					import { flatten, unflatten } from 'flat';
 | 
				
			||||||
import { default as lodash, default as _ } from 'lodash';
 | 
					import { default as lodash, default as _ } from 'lodash';
 | 
				
			||||||
import { ModelCtor } from 'sequelize';
 | 
					import { ModelCtor } from 'sequelize';
 | 
				
			||||||
import { Collection } from './collection';
 | 
					import { Collection } from './collection';
 | 
				
			||||||
@ -121,7 +121,7 @@ export default class FilterParser {
 | 
				
			|||||||
            } else if (typeof opKey === 'function') {
 | 
					            } else if (typeof opKey === 'function') {
 | 
				
			||||||
              skipPrefix = origins.join('.');
 | 
					              skipPrefix = origins.join('.');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
              value = opKey(originalFiler[skipPrefix], {
 | 
					              value = opKey(lodash.get(unflatten(originalFiler), skipPrefix), {
 | 
				
			||||||
                db: this.database,
 | 
					                db: this.database,
 | 
				
			||||||
                path: skipPrefix,
 | 
					                path: skipPrefix,
 | 
				
			||||||
                fieldName: skipPrefix.replace(`.${firstKey}`, ''),
 | 
					                fieldName: skipPrefix.replace(`.${firstKey}`, ''),
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user