NestJS TypeORM Come correttamente il tipo O il condizionale in una query?

0

Domanda

Attualmente ho questo codice per ottenere i miei risultati

rolesCanAssign = await this.rolesRepository.find({
            

where: {
    VALCompany: user.VALCompany,
},

Ma ho bisogno di aggiungere una O l'operatore a questo in CUI e volevo farlo come questo

where: [{VALCompany:user.VALCompany},{isNull(VALCompany)}]

Ottengo un errore che dice che mi aspettavo un '{'. Per il momento, quindi utilizzare la seguente, ma vorrei tipo come nell'esempio precedente

il codice che attualmente lavora per me:

where: 'VALCompany IS NULL or VALCompany IN (' + user.VALCompany + ')'
1

Migliore risposta

1

Il problema è nella seconda parte, si dovrebbe fare:

where: [{VALCompany:user.VALCompany},{VALCompany:isNull()}]
2021-11-23 08:03:41

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................