1602 / 1602/jugglingdb

Add support for advanced queries.

Aperta
#255 3 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
2k
Fork
238
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

If I've understood this correctly, as of now only `AND` conditions are available. Even simple logical `OR` expressions are not supported (at least not in a generic way).

I find [model](https://github.com/mde/model)'s approach quite attractive and since its basic syntax is identical to jugglingdb's, I propose the following syntax:

``` javascript
// Where "foo" is 'BAR' OR "bar" is 'BAZ'
{or: [{foo: 'BAR'}, {bar: 'BAZ'}]}

// Where "foo" is not 'BAR' OR "bar" is null OR "baz" is less than 2112
{or: [{foo {ne: 'BAR'}}, {bar: null}, {baz: {lt: 2112}}]}
```

With negation:

``` javascript
// Where NOT ("foo" is 'BAR' and "bar" is 'BAZ')
{not: {foo: 'BAR', bar: 'BAZ'}}

// Where NOT ("foo" is 'BAZ' and "bar" is less than 1001)
{not: {foo: 'BAZ', bar: {lt: 1001}}}
```

And nested queries:

``` javascript
// Where ("foo" is like 'b' OR "foo" is 'foo') and NOT "foo" is 'baz'
{or: [{foo: {'like': 'b'}}, {foo: 'foo'}], not: {foo: 'baz'}}
```

In my opinion, at least basic `OR` conditions are quite essential for an ORM. If this could somehow be addressed, that would be great.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

The issue is about adding OR and NOT query support to jugglingdb's ORM. Start by examining the query builder and adapter layers, likely in lib/adapters and lib/schema. Look at how AND conditions are currently parsed and translated to database-specific queries. Test changes with one adapter first, such as memory or sqlite, to verify the new syntax works. Ensure the feature works across all supported databases by checking each adapter's query translation.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, mongodb, mysql, nodejs, postgresql, redis, sqlite
Ambito
backend, database
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.