diff --git a/src/BaseFirestoreRepository.spec.ts b/src/BaseFirestoreRepository.spec.ts index 10b6fc28..3b485c67 100644 --- a/src/BaseFirestoreRepository.spec.ts +++ b/src/BaseFirestoreRepository.spec.ts @@ -49,8 +49,7 @@ describe('BaseRepository', () => { entity.id = 'perfect-circle'; entity.name = 'A Perfect Circle'; entity.formationYear = 1999; - entity.genres = ['alternative-rock', 'alternative-metal', 'hard-rock'] - + entity.genres = ['alternative-rock', 'alternative-metal', 'hard-rock']; const band = await bandRepository.create(entity); expect(band.id).to.equal(entity.id); @@ -95,7 +94,9 @@ describe('BaseRepository', () => { }); it('must filter with whereEqualTo', async () => { - const list = await bandRepository.whereEqualTo('name', 'Porcupine Tree').find(); + const list = await bandRepository + .whereEqualTo('name', 'Porcupine Tree') + .find(); expect(list.length).to.equal(1); expect(list[0].name).to.equal('Porcupine Tree'); }); @@ -118,6 +119,7 @@ describe('BaseRepository', () => { const list = await bandRepository .whereLessThan('formationYear', 1983) .find(); + expect(list.length).to.equal(1); }); @@ -128,16 +130,16 @@ describe('BaseRepository', () => { expect(list.length).to.equal(2); }); - it('must filter with whereArrayCointain', async () => { + it('must filter with whereArrayContains', async () => { const list = await bandRepository - .whereArrayCointain('genres', 'progressive-rock') + .whereArrayContains('genres', 'progressive-rock') .find(); expect(list.length).to.equal(2); }); it('must filter with two or more operators', async () => { const list = await bandRepository .whereLessOrEqualThan('formationYear', 1983) - .whereArrayCointain('genres', 'funk-rock') + .whereArrayContains('genres', 'funk-rock') .find(); expect(list.length).to.equal(1); expect(list[0].id).to.equal('red-hot-chili-peppers'); @@ -153,7 +155,7 @@ describe('BaseRepository', () => { it('should be able to execute operations in the subcollection', async () => { const band = await bandRepository.findById('red-hot-chili-peppers'); - const bestAlbum = await band.albums.findById('stadium-arcadium') + const bestAlbum = await band.albums.findById('stadium-arcadium'); expect(bestAlbum.id).to.equal('stadium-arcadium'); }); }); diff --git a/src/BaseFirestoreRepository.ts b/src/BaseFirestoreRepository.ts index 773c97de..2075e656 100644 --- a/src/BaseFirestoreRepository.ts +++ b/src/BaseFirestoreRepository.ts @@ -187,8 +187,8 @@ export default class BaseFirestoreRepository ); } - whereArrayCointain(prop: keyof T, val: IFirestoreVal): QueryBuilder { - return new QueryBuilder(this.firestoreCollection).whereArrayCointain( + whereArrayContains(prop: keyof T, val: IFirestoreVal): QueryBuilder { + return new QueryBuilder(this.firestoreCollection).whereArrayContains( prop, val ); diff --git a/src/QueryBuilder.ts b/src/QueryBuilder.ts index 820c1d77..32c1748f 100644 --- a/src/QueryBuilder.ts +++ b/src/QueryBuilder.ts @@ -65,7 +65,7 @@ export default class QueryBuilder return this; } - whereArrayCointain(prop: keyof T, val: IFirestoreVal): QueryBuilder { + whereArrayContains(prop: keyof T, val: IFirestoreVal): QueryBuilder { this.queries.push({ prop: prop.toString(), val, diff --git a/src/types.ts b/src/types.ts index 230f34c8..c33867ab 100644 --- a/src/types.ts +++ b/src/types.ts @@ -35,7 +35,7 @@ export interface IQueryBuilder { whereGreaterOrEqualThan(prop: keyof T, val: IFirestoreVal): IQueryBuilder; whereLessThan(prop: keyof T, val: IFirestoreVal): IQueryBuilder; whereLessOrEqualThan(prop: keyof T, val: IFirestoreVal): IQueryBuilder; - whereArrayCointain(prop: keyof T, val: IFirestoreVal): IQueryBuilder; + whereArrayContains(prop: keyof T, val: IFirestoreVal): IQueryBuilder; find(): Promise; }