vsrepo 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -5
- package/VSRepository/VSRepository.d.ts +879 -873
- package/VSRepository/VSRepository.js +31 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -497,6 +497,8 @@ Os filtros são sufixos aplicados ao nome do campo dentro do método. O campo em
|
|
|
497
497
|
| `GreaterThanEqual` | `gte` | sim |
|
|
498
498
|
| `LessThan` | `lt` | sim |
|
|
499
499
|
| `LessThanEqual` | `lte` | sim |
|
|
500
|
+
| `Between` | `gte` + `lte` | sim (tupla `[min, max]`) |
|
|
501
|
+
| `NotBetween` | `not.gte` + `not.lte` | sim (tupla `[min, max]`) |
|
|
500
502
|
| `IsNull` | `null` | não |
|
|
501
503
|
| `IsNotNull` | `not: null` | não |
|
|
502
504
|
| `IsTrue` | `true` | não |
|
|
@@ -511,6 +513,37 @@ findByEmailStartsWithInsensitive // { email: { startsWith: valor, mode: 'insensi
|
|
|
511
513
|
findByNomeInsensitive // { nome: { equals: valor, mode: 'insensitive' } }
|
|
512
514
|
```
|
|
513
515
|
|
|
516
|
+
`Between` e `NotBetween` recebem uma **tupla `[minValue, maxValue]`** e são ideais para filtros de intervalo em números, datas ou qualquer campo comparável:
|
|
517
|
+
|
|
518
|
+
```ts
|
|
519
|
+
methods: {
|
|
520
|
+
findManyByIdadeBetween: { map: true },
|
|
521
|
+
findManyBySalarioNotBetween: { map: true },
|
|
522
|
+
findManyByCriadoEmBetween: { map: true },
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
// Uso
|
|
526
|
+
await usuarioRepository.findManyByIdadeBetween([18, 65]);
|
|
527
|
+
await usuarioRepository.findManyBySalarioNotBetween([1000, 5000]);
|
|
528
|
+
await usuarioRepository.findManyByCriadoEmBetween([new Date("2024-01-01"), new Date("2024-12-31")]);
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Gera (`findManyByIdadeBetween`):
|
|
532
|
+
|
|
533
|
+
```ts
|
|
534
|
+
{
|
|
535
|
+
idade: { gte: 18, lte: 65 }
|
|
536
|
+
}
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Gera (`findManyBySalarioNotBetween`):
|
|
540
|
+
|
|
541
|
+
```ts
|
|
542
|
+
{
|
|
543
|
+
salario: { not: { gte: 1000, lte: 5000 } }
|
|
544
|
+
}
|
|
545
|
+
```
|
|
546
|
+
|
|
514
547
|
O sufixo `Optional` pode ser adicionado a qualquer campo para tornar o argumento opcional:
|
|
515
548
|
|
|
516
549
|
```ts
|
|
@@ -621,14 +654,18 @@ Exemplos:
|
|
|
621
654
|
|
|
622
655
|
```ts
|
|
623
656
|
methods: {
|
|
624
|
-
findByPostagensSomeTituloContains: { map: true }, // postagens: { some: { titulo: { contains: valor } } }
|
|
625
|
-
|
|
626
|
-
findByPerfilWithout: { map: true }, // perfil: { isNot: {} }
|
|
627
|
-
findByPostagensSome: { map: true }, // postagens: { some: {} }
|
|
628
|
-
findByPostagensEveryAtivoIsTrue: { map: true }, // postagens: { every: { ativo: true } }
|
|
657
|
+
findByPostagensSomeTituloContains: { map: true }, // postagens: { some: { titulo: { contains: valor } } } >> (Busca usuários que o título de alguma postagem contém um valor)
|
|
658
|
+
findByPerfilWithDescricaoIsNotNull: { map: true }, // perfil: { is: { descricao: { not: null } } } >> (Busca usuários em que a descrição do perfil não é nula)
|
|
659
|
+
findByPerfilWithout: { map: true }, // perfil: { isNot: {} } >> (Busca usuários sem perfil)
|
|
660
|
+
findByPostagensSome: { map: true }, // postagens: { some: {} } >> (Busca usuários com alguma postagem)
|
|
661
|
+
findByPostagensEveryAtivoIsTrue: { map: true }, // postagens: { every: { ativo: true } } >> (Busca usuários que todas as postagens estão ativas)
|
|
662
|
+
findByPostagensNone: { map: true }, // postagens: { none: {} } >> (Busca usuários sem postagens)
|
|
629
663
|
}
|
|
630
664
|
```
|
|
631
665
|
|
|
666
|
+
> [!NOTE]
|
|
667
|
+
> Teoricamente você pode usar `Every` sem `Field` (ele geraria { every: {} }), porém isso não produz um filtro efetivo. A condição é considerada verdadeira para qualquer relação, inclusive quando não existem registros relacionados, tornando o resultado equivalente a não aplicar filtro algum.
|
|
668
|
+
|
|
632
669
|
---
|
|
633
670
|
|
|
634
671
|
### Sufixos de paginação e ordenação
|