querymongo 1.1.1 → 1.4.0
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/CHANGELOG.md +6 -0
- package/README.md +641 -41
- package/dist/application/MongoConverter.js +1 -1
- package/dist/application/MongoConverter.js.map +1 -1
- package/dist/application/MongoConverter.spec.js +136 -4
- package/dist/application/MongoConverter.spec.js.map +1 -1
- package/dist/cli/main.js +2 -11
- package/dist/cli/main.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/converters/ConverterFactory.js +2 -0
- package/dist/infrastructure/converters/ConverterFactory.js.map +1 -1
- package/dist/infrastructure/converters/ConverterFactory.spec.js +51 -0
- package/dist/infrastructure/converters/ConverterFactory.spec.js.map +1 -0
- package/dist/infrastructure/converters/JoinConverter.js +49 -0
- package/dist/infrastructure/converters/JoinConverter.js.map +1 -0
- package/dist/infrastructure/converters/SelectConverter.js +7 -8
- package/dist/infrastructure/converters/SelectConverter.js.map +1 -1
- package/dist/infrastructure/utils/queryUtils.js +22 -6
- package/dist/infrastructure/utils/queryUtils.js.map +1 -1
- package/dist/infrastructure/utils/queryUtils.spec.js +261 -0
- package/dist/infrastructure/utils/queryUtils.spec.js.map +1 -0
- package/dist/types/application/MongoConverter.d.ts +2 -1
- package/dist/types/application/MongoConverter.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/infrastructure/converters/ConverterFactory.d.ts.map +1 -1
- package/dist/types/infrastructure/converters/ConverterFactory.spec.d.ts +2 -0
- package/dist/types/infrastructure/converters/ConverterFactory.spec.d.ts.map +1 -0
- package/dist/types/infrastructure/converters/JoinConverter.d.ts +7 -0
- package/dist/types/infrastructure/converters/JoinConverter.d.ts.map +1 -0
- package/dist/types/infrastructure/converters/SelectConverter.d.ts.map +1 -1
- package/dist/types/infrastructure/utils/queryUtils.d.ts +7 -2
- package/dist/types/infrastructure/utils/queryUtils.d.ts.map +1 -1
- package/dist/types/infrastructure/utils/queryUtils.spec.d.ts +2 -0
- package/dist/types/infrastructure/utils/queryUtils.spec.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,11 +4,12 @@ SQL to MongoDB Query Converter CLI - Convierte queries SQL a MongoDB format de f
|
|
|
4
4
|
|
|
5
5
|
## 📋 Características
|
|
6
6
|
|
|
7
|
-
✅ **Convertir SELECT queries** - Con proyecciones, filtros y límites
|
|
8
|
-
✅ **Convertir INSERT queries** - Para inserción de documentos
|
|
9
|
-
✅ **Convertir UPDATE queries** - Con filtros y actualizaciones
|
|
10
|
-
✅ **Convertir DELETE queries** - Para eliminación
|
|
7
|
+
✅ **Convertir SELECT queries** - Con proyecciones, filtros, LIKE, IN y límites
|
|
8
|
+
✅ **Convertir INSERT queries** - Para inserción de documentos únicos o múltiples
|
|
9
|
+
✅ **Convertir UPDATE queries** - Con filtros y actualizaciones en uno o muchos documentos
|
|
10
|
+
✅ **Convertir DELETE queries** - Para eliminación con condiciones complejas
|
|
11
11
|
✅ **CLI interactiva** - Modo interactivo para pruebas rápidas
|
|
12
|
+
✅ **Convertir JOIN queries** - INNER JOIN y LEFT JOIN entre colecciones
|
|
12
13
|
✅ **API TypeScript** - Para uso como librería en tus proyectos
|
|
13
14
|
|
|
14
15
|
## 🏗️ Arquitectura
|
|
@@ -28,6 +29,7 @@ src/
|
|
|
28
29
|
│ │ ├── CreateConverter.ts # Estrategia INSERT
|
|
29
30
|
│ │ ├── UpdateConverter.ts # Estrategia UPDATE
|
|
30
31
|
│ │ ├── DeleteConverter.ts # Estrategia DELETE
|
|
32
|
+
│ │ ├── JoinConverter.ts # Estrategia JOIN
|
|
31
33
|
│ │ └── ConverterFactory.ts # Factory + Strategy Pattern
|
|
32
34
|
│ └── utils/
|
|
33
35
|
│ └── queryUtils.ts # Utilidades compartidas (DRY)
|
|
@@ -74,68 +76,662 @@ npm run dev interactive
|
|
|
74
76
|
|
|
75
77
|
Esto abrirá la CLI interactiva donde puedes ingresar queries SQL y recibir instantáneamente el equivalente en MongoDB.
|
|
76
78
|
|
|
79
|
+
### 📦 Uso como Librería
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { mongoConverter } from "querymongo";
|
|
83
|
+
|
|
84
|
+
const sql = "SELECT name, email FROM users WHERE age > 18";
|
|
85
|
+
const result = mongoConverter.convert(sql);
|
|
86
|
+
console.log(result);
|
|
87
|
+
```
|
|
88
|
+
|
|
77
89
|
## 📚 Ejemplos de Conversión
|
|
78
90
|
|
|
79
|
-
### SELECT
|
|
91
|
+
### SELECT - Casos Básicos
|
|
92
|
+
|
|
93
|
+
#### SELECT simple (todos los documentos)
|
|
94
|
+
|
|
95
|
+
```sql
|
|
96
|
+
SELECT * FROM users
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Salida del Conversor:**
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"collection": "users",
|
|
104
|
+
"queryType": "find",
|
|
105
|
+
"pipeline": [
|
|
106
|
+
{
|
|
107
|
+
"$match": {}
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"$project": {}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### SELECT con campos específicos
|
|
80
117
|
|
|
81
118
|
```sql
|
|
82
119
|
SELECT name, email FROM users
|
|
83
120
|
```
|
|
84
121
|
|
|
85
|
-
**
|
|
122
|
+
**Salida del Conversor:**
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"collection": "users",
|
|
127
|
+
"queryType": "find",
|
|
128
|
+
"pipeline": [
|
|
129
|
+
{
|
|
130
|
+
"$match": {}
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"$project": {
|
|
134
|
+
"name": 1,
|
|
135
|
+
"email": 1
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### SELECT - Filtros y Condiciones
|
|
143
|
+
|
|
144
|
+
#### SELECT con WHERE simple
|
|
145
|
+
|
|
146
|
+
```sql
|
|
147
|
+
SELECT * FROM users WHERE status = 'active'
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Salida del Conversor:**
|
|
151
|
+
|
|
152
|
+
```json
|
|
153
|
+
{
|
|
154
|
+
"collection": "users",
|
|
155
|
+
"queryType": "find",
|
|
156
|
+
"pipeline": [
|
|
157
|
+
{
|
|
158
|
+
"$match": {
|
|
159
|
+
"status": {
|
|
160
|
+
"$eq": "active"
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"$project": {}
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### SELECT con comparación
|
|
172
|
+
|
|
173
|
+
```sql
|
|
174
|
+
SELECT * FROM products WHERE price > 100
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
**Salida del Conversor:**
|
|
178
|
+
|
|
179
|
+
```json
|
|
180
|
+
{
|
|
181
|
+
"collection": "products",
|
|
182
|
+
"queryType": "find",
|
|
183
|
+
"pipeline": [
|
|
184
|
+
{
|
|
185
|
+
"$match": {
|
|
186
|
+
"price": {
|
|
187
|
+
"$gt": 100
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
"$project": {}
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### SELECT con múltiples condiciones (AND)
|
|
199
|
+
|
|
200
|
+
```sql
|
|
201
|
+
SELECT * FROM users WHERE age >= 18 AND status = 'active'
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Salida del Conversor:**
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"collection": "users",
|
|
209
|
+
"queryType": "find",
|
|
210
|
+
"pipeline": [
|
|
211
|
+
{
|
|
212
|
+
"$match": {
|
|
213
|
+
"$and": [
|
|
214
|
+
{
|
|
215
|
+
"age": {
|
|
216
|
+
"$gte": 18
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"status": {
|
|
221
|
+
"$eq": "active"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"$project": {}
|
|
229
|
+
}
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
#### SELECT con múltiples condiciones (OR)
|
|
235
|
+
|
|
236
|
+
```sql
|
|
237
|
+
SELECT * FROM users WHERE status = 'active' OR status = 'pending'
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Salida del Conversor:**
|
|
241
|
+
|
|
242
|
+
```json
|
|
243
|
+
{
|
|
244
|
+
"collection": "users",
|
|
245
|
+
"queryType": "find",
|
|
246
|
+
"pipeline": [
|
|
247
|
+
{
|
|
248
|
+
"$match": {
|
|
249
|
+
"$or": [
|
|
250
|
+
{
|
|
251
|
+
"status": {
|
|
252
|
+
"$eq": "active"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"status": {
|
|
257
|
+
"$eq": "pending"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"$project": {}
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
#### SELECT con LIKE (búsqueda por patrón)
|
|
271
|
+
|
|
272
|
+
```sql
|
|
273
|
+
SELECT * FROM users WHERE email LIKE '%@gmail.com'
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
**Salida del Conversor:**
|
|
277
|
+
|
|
278
|
+
```json
|
|
279
|
+
{
|
|
280
|
+
"collection": "users",
|
|
281
|
+
"queryType": "find",
|
|
282
|
+
"pipeline": [
|
|
283
|
+
{
|
|
284
|
+
"$match": {
|
|
285
|
+
"email": {
|
|
286
|
+
"$regex": "%@gmail.com"
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"$project": {}
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### SELECT con IN
|
|
298
|
+
|
|
299
|
+
```sql
|
|
300
|
+
SELECT * FROM products WHERE category IN ('electronics', 'books', 'clothing')
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Salida del Conversor:**
|
|
304
|
+
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"collection": "products",
|
|
308
|
+
"queryType": "find",
|
|
309
|
+
"pipeline": [
|
|
310
|
+
{
|
|
311
|
+
"$match": {
|
|
312
|
+
"category": {
|
|
313
|
+
"$in": [
|
|
314
|
+
{
|
|
315
|
+
"type": "single_quote_string",
|
|
316
|
+
"value": "electronics"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"type": "single_quote_string",
|
|
320
|
+
"value": "books"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"type": "single_quote_string",
|
|
324
|
+
"value": "clothing"
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
"$project": {}
|
|
332
|
+
}
|
|
333
|
+
]
|
|
334
|
+
}
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### SELECT - Proyecciones y Límites
|
|
338
|
+
|
|
339
|
+
#### SELECT con LIMIT
|
|
340
|
+
|
|
341
|
+
```sql
|
|
342
|
+
SELECT * FROM users LIMIT 5
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
**Salida del Conversor:**
|
|
346
|
+
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"collection": "users",
|
|
350
|
+
"queryType": "find",
|
|
351
|
+
"pipeline": [
|
|
352
|
+
{
|
|
353
|
+
"$match": {}
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
"$project": {}
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"$limit": 5
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### SELECT con campos, filtro y límite
|
|
366
|
+
|
|
367
|
+
```sql
|
|
368
|
+
SELECT name, age FROM users WHERE age >= 18 LIMIT 10
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Salida del Conversor:**
|
|
372
|
+
|
|
373
|
+
```json
|
|
374
|
+
{
|
|
375
|
+
"collection": "users",
|
|
376
|
+
"queryType": "aggregation",
|
|
377
|
+
"pipeline": [
|
|
378
|
+
{
|
|
379
|
+
"$match": {
|
|
380
|
+
"age": {
|
|
381
|
+
"$gte": 18
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"$project": {
|
|
387
|
+
"name": 1,
|
|
388
|
+
"age": 1
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"$limit": 10
|
|
393
|
+
}
|
|
394
|
+
]
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
### INSERT - Inserción de Documentos
|
|
401
|
+
|
|
402
|
+
#### INSERT simple
|
|
403
|
+
|
|
404
|
+
```sql
|
|
405
|
+
INSERT INTO users (name, email, age) VALUES ('John Doe', 'john@example.com', 30)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
**Salida del Conversor:**
|
|
409
|
+
|
|
410
|
+
```json
|
|
411
|
+
{
|
|
412
|
+
"collection": "users",
|
|
413
|
+
"operation": "insertOne",
|
|
414
|
+
"documents": {
|
|
415
|
+
"name": "John Doe",
|
|
416
|
+
"email": "john@example.com",
|
|
417
|
+
"age": 30
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
#### INSERT múltiple en una sola operación
|
|
423
|
+
|
|
424
|
+
```sql
|
|
425
|
+
INSERT INTO users (name, email) VALUES
|
|
426
|
+
('Alice', 'alice@example.com'),
|
|
427
|
+
('Bob', 'bob@example.com'),
|
|
428
|
+
('Charlie', 'charlie@example.com')
|
|
429
|
+
```
|
|
86
430
|
|
|
87
|
-
|
|
88
|
-
|
|
431
|
+
**Salida del Conversor:**
|
|
432
|
+
|
|
433
|
+
```json
|
|
434
|
+
{
|
|
435
|
+
"collection": "users",
|
|
436
|
+
"operation": "insertMany",
|
|
437
|
+
"documents": [
|
|
438
|
+
{ "name": "Alice", "email": "alice@example.com" },
|
|
439
|
+
{ "name": "Bob", "email": "bob@example.com" },
|
|
440
|
+
{ "name": "Charlie", "email": "charlie@example.com" }
|
|
441
|
+
]
|
|
442
|
+
}
|
|
89
443
|
```
|
|
90
444
|
|
|
91
|
-
|
|
445
|
+
#### INSERT con valores numéricos y tipos diversos
|
|
92
446
|
|
|
93
447
|
```sql
|
|
94
|
-
|
|
448
|
+
INSERT INTO products (name, price, quantity, rating)
|
|
449
|
+
VALUES ('Laptop', 999.99, 5, 4.5)
|
|
95
450
|
```
|
|
96
451
|
|
|
97
|
-
**
|
|
452
|
+
**Salida del Conversor:**
|
|
453
|
+
|
|
454
|
+
```json
|
|
455
|
+
{
|
|
456
|
+
"collection": "products",
|
|
457
|
+
"operation": "insertOne",
|
|
458
|
+
"documents": {
|
|
459
|
+
"name": "Laptop",
|
|
460
|
+
"price": 999.99,
|
|
461
|
+
"quantity": 5,
|
|
462
|
+
"rating": 4.5
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
### UPDATE - Actualización de Documentos
|
|
470
|
+
|
|
471
|
+
#### UPDATE con WHERE (updateOne)
|
|
98
472
|
|
|
99
|
-
```
|
|
100
|
-
|
|
473
|
+
```sql
|
|
474
|
+
UPDATE users SET status = 'inactive' WHERE id = 1
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
**Salida del Conversor:**
|
|
478
|
+
|
|
479
|
+
```json
|
|
480
|
+
{
|
|
481
|
+
"collection": "users",
|
|
482
|
+
"operation": "updateOne",
|
|
483
|
+
"filter": {
|
|
484
|
+
"id": {
|
|
485
|
+
"$eq": 1
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
"update": {
|
|
489
|
+
"$set": {
|
|
490
|
+
"status": "inactive"
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
101
494
|
```
|
|
102
495
|
|
|
103
|
-
|
|
496
|
+
#### UPDATE múltiples campos
|
|
104
497
|
|
|
105
498
|
```sql
|
|
106
|
-
|
|
499
|
+
UPDATE users SET status = 'active', last_login = '2026-09-21' WHERE email = 'john@example.com'
|
|
107
500
|
```
|
|
108
501
|
|
|
109
|
-
**
|
|
502
|
+
**Salida del Conversor:**
|
|
503
|
+
|
|
504
|
+
```json
|
|
505
|
+
{
|
|
506
|
+
"collection": "users",
|
|
507
|
+
"operation": "updateOne",
|
|
508
|
+
"filter": {
|
|
509
|
+
"email": {
|
|
510
|
+
"$eq": "john@example.com"
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
"update": {
|
|
514
|
+
"$set": {
|
|
515
|
+
"status": "active",
|
|
516
|
+
"last_login": "2026-09-21"
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
```
|
|
110
521
|
|
|
111
|
-
|
|
112
|
-
|
|
522
|
+
#### UPDATE múltiples documentos (updateMany)
|
|
523
|
+
|
|
524
|
+
```sql
|
|
525
|
+
UPDATE products SET discount = 10 WHERE price > 500
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
**Salida del Conversor:**
|
|
529
|
+
|
|
530
|
+
```json
|
|
531
|
+
{
|
|
532
|
+
"collection": "products",
|
|
533
|
+
"operation": "updateMany",
|
|
534
|
+
"filter": { "price": { "$gt": 500 } },
|
|
535
|
+
"update": { "$set": { "discount": 10 } }
|
|
536
|
+
}
|
|
113
537
|
```
|
|
114
538
|
|
|
115
|
-
|
|
539
|
+
#### UPDATE todos los documentos
|
|
116
540
|
|
|
117
541
|
```sql
|
|
118
|
-
UPDATE users SET
|
|
542
|
+
UPDATE users SET status = 'archived'
|
|
119
543
|
```
|
|
120
544
|
|
|
121
|
-
**
|
|
545
|
+
**Salida del Conversor:**
|
|
122
546
|
|
|
123
|
-
```
|
|
124
|
-
|
|
547
|
+
```json
|
|
548
|
+
{
|
|
549
|
+
"collection": "users",
|
|
550
|
+
"operation": "updateMany",
|
|
551
|
+
"filter": {},
|
|
552
|
+
"update": { "$set": { "status": "archived" } }
|
|
553
|
+
}
|
|
125
554
|
```
|
|
126
555
|
|
|
127
|
-
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
### DELETE - Eliminación de Documentos
|
|
559
|
+
|
|
560
|
+
#### DELETE con WHERE (deleteOne)
|
|
128
561
|
|
|
129
562
|
```sql
|
|
130
563
|
DELETE FROM users WHERE id = 1
|
|
131
564
|
```
|
|
132
565
|
|
|
133
|
-
**
|
|
566
|
+
**Salida del Conversor:**
|
|
567
|
+
|
|
568
|
+
```json
|
|
569
|
+
{
|
|
570
|
+
"collection": "users",
|
|
571
|
+
"operation": "deleteOne",
|
|
572
|
+
"filter": {
|
|
573
|
+
"id": {
|
|
574
|
+
"$eq": 1
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
#### DELETE múltiples documentos
|
|
581
|
+
|
|
582
|
+
```sql
|
|
583
|
+
DELETE FROM users WHERE age < 18
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
**Salida del Conversor:**
|
|
134
587
|
|
|
135
|
-
```
|
|
136
|
-
|
|
588
|
+
```json
|
|
589
|
+
{
|
|
590
|
+
"collection": "users",
|
|
591
|
+
"operation": "deleteMany",
|
|
592
|
+
"filter": { "age": { "$lt": 18 } }
|
|
593
|
+
}
|
|
137
594
|
```
|
|
138
595
|
|
|
596
|
+
#### DELETE con múltiples condiciones (AND)
|
|
597
|
+
|
|
598
|
+
```sql
|
|
599
|
+
DELETE FROM users WHERE status = 'inactive' AND created_at < '2023-01-01'
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
**Salida del Conversor:**
|
|
603
|
+
|
|
604
|
+
```json
|
|
605
|
+
{
|
|
606
|
+
"collection": "users",
|
|
607
|
+
"operation": "deleteMany",
|
|
608
|
+
"filter": {
|
|
609
|
+
"$and": [
|
|
610
|
+
{
|
|
611
|
+
"status": {
|
|
612
|
+
"$eq": "inactive"
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"created_at": {
|
|
617
|
+
"$lt": "2023-01-01"
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
#### DELETE con IN
|
|
626
|
+
|
|
627
|
+
```sql
|
|
628
|
+
DELETE FROM products WHERE id IN (1, 5, 10)
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
**Salida del Conversor:**
|
|
632
|
+
|
|
633
|
+
```json
|
|
634
|
+
{
|
|
635
|
+
"collection": "products",
|
|
636
|
+
"operation": "deleteMany",
|
|
637
|
+
"filter": { "id": { "$in": [1, 5, 10] } }
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
#### ⚠️ DELETE todos los documentos
|
|
642
|
+
|
|
643
|
+
```sql
|
|
644
|
+
DELETE FROM users
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
**Salida del Conversor:**
|
|
648
|
+
|
|
649
|
+
```json
|
|
650
|
+
{
|
|
651
|
+
"collection": "users",
|
|
652
|
+
"operation": "deleteMany",
|
|
653
|
+
"filter": {}
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
### JOIN - Uniones entre Colecciones
|
|
660
|
+
|
|
661
|
+
#### INNER JOIN simple
|
|
662
|
+
|
|
663
|
+
```sql
|
|
664
|
+
SELECT u.name, o.order_id FROM users u INNER JOIN orders o ON u.id = o.user_id
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**Salida del Conversor:**
|
|
668
|
+
|
|
669
|
+
```json
|
|
670
|
+
{
|
|
671
|
+
"collection": "users",
|
|
672
|
+
"pipeline": [
|
|
673
|
+
{
|
|
674
|
+
"$lookup": {
|
|
675
|
+
"from": "orders",
|
|
676
|
+
"localField": "id",
|
|
677
|
+
"foreignField": "user_id",
|
|
678
|
+
"as": "o"
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
"$unwind": {
|
|
683
|
+
"path": "$o",
|
|
684
|
+
"preserveNullAndEmptyArrays": false
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
"$project": {
|
|
689
|
+
"name": 1,
|
|
690
|
+
"order_id": 1
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
]
|
|
694
|
+
}
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
#### LEFT JOIN
|
|
698
|
+
|
|
699
|
+
```sql
|
|
700
|
+
SELECT u.name, o.order_id FROM users u LEFT JOIN orders o ON u.id = o.user_id
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
**Salida del Conversor:**
|
|
704
|
+
|
|
705
|
+
```json
|
|
706
|
+
{
|
|
707
|
+
"collection": "users",
|
|
708
|
+
"pipeline": [
|
|
709
|
+
{
|
|
710
|
+
"$lookup": {
|
|
711
|
+
"from": "orders",
|
|
712
|
+
"localField": "id",
|
|
713
|
+
"foreignField": "user_id",
|
|
714
|
+
"as": "o"
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
"$unwind": {
|
|
719
|
+
"path": "$o",
|
|
720
|
+
"preserveNullAndEmptyArrays": true
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
"$project": {
|
|
725
|
+
"name": 1,
|
|
726
|
+
"order_id": 1
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
]
|
|
730
|
+
}
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
---
|
|
734
|
+
|
|
139
735
|
## 🧪 Testing
|
|
140
736
|
|
|
141
737
|
```bash
|
|
@@ -146,17 +742,20 @@ Cobertura: **100%** en líneas y funciones.
|
|
|
146
742
|
|
|
147
743
|
## 🔧 Operadores Soportados
|
|
148
744
|
|
|
149
|
-
| SQL | MongoDB
|
|
150
|
-
| ----------- |
|
|
151
|
-
| `=` | `$eq`
|
|
152
|
-
| `!=` o `<>` | `$ne`
|
|
153
|
-
| `<` | `$lt`
|
|
154
|
-
| `>` | `$gt`
|
|
155
|
-
| `<=` | `$lte`
|
|
156
|
-
| `>=` | `$gte`
|
|
157
|
-
| `LIKE` | `$regex` |
|
|
158
|
-
| `IN` | `$in`
|
|
159
|
-
| `NOT IN` | `$nin`
|
|
745
|
+
| SQL | MongoDB | Descripción |
|
|
746
|
+
| ----------- | --------- | ----------------------- |
|
|
747
|
+
| `=` | `$eq` | Igualdad |
|
|
748
|
+
| `!=` o `<>` | `$ne` | No igual |
|
|
749
|
+
| `<` | `$lt` | Menor que |
|
|
750
|
+
| `>` | `$gt` | Mayor que |
|
|
751
|
+
| `<=` | `$lte` | Menor o igual |
|
|
752
|
+
| `>=` | `$gte` | Mayor o igual |
|
|
753
|
+
| `LIKE` | `$regex` | Búsqueda por patrón |
|
|
754
|
+
| `IN` | `$in` | Dentro de lista |
|
|
755
|
+
| `NOT IN` | `$nin` | Fuera de lista |
|
|
756
|
+
| `AND` | `$and` | Operador lógico Y |
|
|
757
|
+
| `OR` | `$or` | Operador lógico O |
|
|
758
|
+
| `JOIN` | `$lookup` | Unión entre colecciones |
|
|
160
759
|
|
|
161
760
|
## 📦 Dependencias
|
|
162
761
|
|
|
@@ -168,11 +767,12 @@ Cobertura: **100%** en líneas y funciones.
|
|
|
168
767
|
|
|
169
768
|
## 🎯 Próximas Mejoras
|
|
170
769
|
|
|
171
|
-
- [ ] Soporte para
|
|
172
|
-
- [ ] Soporte para
|
|
173
|
-
- [ ] Soporte para ORDER BY
|
|
770
|
+
- [ ] Soporte para GROUP BY y agregaciones
|
|
771
|
+
- [ ] Soporte para ORDER BY y sorting
|
|
174
772
|
- [ ] Transacciones multi-documento
|
|
175
773
|
- [ ] Validación de esquema
|
|
774
|
+
- [ ] Soporte para DISTINCT
|
|
775
|
+
- [ ] Operadores de texto ($text)
|
|
176
776
|
|
|
177
777
|
## 📄 Licencia
|
|
178
778
|
|