1602 / 1602/jugglingdb

Add support for advanced queries.

Abierto
#255 3 comentarios 1 reacción 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
2k
Forks
238
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, mongodb, mysql, nodejs, postgresql, redis, sqlite
Área
backend, database
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.