You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT category, COUNT(*) as count, AVG(price) as avg_price FROM products GROUP BY category
240
+
241
+
-- JOIN between users and orders
242
+
SELECTu.name, o.total, o.statusFROM users u JOIN orders o ONu._id=o.userIdWHEREo.total>100
243
+
```
244
+
245
+
Check out the [examples folder](src/examples/) for more complete examples, including how to set up the QueryLeaf instance and execute these queries.
246
+
247
+
This library demonstrates:
97
248
- Basic SELECT queries
98
249
- Filtering with WHERE clauses
99
250
- Sorting with ORDER BY
@@ -105,7 +256,7 @@ This example demonstrates:
105
256
106
257
## Architecture
107
258
108
-
Squongo follows a modular architecture:
259
+
QueryLeaf follows a modular architecture:
109
260
110
261
1.**SqlParser**: Converts SQL text into an abstract syntax tree (AST) using node-sql-parser
111
262
2.**SqlCompiler**: Transforms the AST into MongoDB commands
@@ -122,9 +273,11 @@ The project includes both unit tests and integration tests:
122
273
Run unit tests with:
123
274
124
275
```bash
125
-
npm test
276
+
npm run test:unit
126
277
```
127
278
279
+
Unit tests are located in the `tests/unit` directory and focus on testing the parsing and compilation of SQL statements without requiring a database connection.
280
+
128
281
#### Integration Tests
129
282
130
283
Integration tests use [testcontainers](https://github.com/testcontainers/testcontainers-node) to spin up a MongoDB instance in Docker. Make sure you have Docker installed and running before executing these tests.
@@ -135,13 +288,21 @@ Run integration tests with:
135
288
npm run test:integration
136
289
```
137
290
291
+
Integration tests are located in the `tests/integration` directory and test the complete functionality with a real MongoDB database.
292
+
138
293
These tests will:
139
294
1. Start a MongoDB container
140
295
2. Load fixture data
141
296
3. Run a series of SQL queries against the database
142
297
4. Verify the results
143
298
5. Clean up the container when done
144
299
300
+
To run all tests:
301
+
302
+
```bash
303
+
npm run test:all
304
+
```
305
+
145
306
### Continuous Integration
146
307
147
308
This project uses GitHub Actions for continuous integration. The CI workflow automatically runs on:
@@ -151,12 +312,33 @@ This project uses GitHub Actions for continuous integration. The CI workflow aut
151
312
The CI workflow:
152
313
1. Sets up Node.js (versions 16.x, 18.x, and 20.x)
153
314
2. Installs dependencies
154
-
3. Runs all tests (including integration tests with MongoDB in a Docker container)
155
-
4. Performs type checking
156
-
5. Builds the package
315
+
3. Runs unit tests
316
+
4. Runs integration tests with MongoDB in a Docker container
317
+
5. Performs type checking
318
+
6. Builds the package
157
319
158
320
You can see the workflow configuration in `.github/workflows/test.yml`.
159
321
322
+
## Documentation
323
+
324
+
Comprehensive documentation is available at [queryleaf.com/docs](https://queryleaf.com/docs), including:
325
+
326
+
- Detailed installation and setup guides
327
+
- In-depth explanation of supported SQL syntax
328
+
- Usage examples and best practices
329
+
- Troubleshooting and debugging guides
330
+
- Performance optimization tips
331
+
332
+
For local development, you can run the documentation site with:
This directory contains the source files for the QueryLeaf documentation site. The documentation is built using [MkDocs](https://www.mkdocs.org/) with the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) theme.
4
+
5
+
## Viewing the Documentation
6
+
7
+
You can view the documentation in several ways:
8
+
9
+
1.**Online**: Visit the published documentation at [queryleaf.com/docs](https://queryleaf.com/docs)
10
+
11
+
2.**Locally**: Run the documentation server locally with:
12
+
```bash
13
+
npm run docs:serve
14
+
```
15
+
Then open your browser to [http://localhost:8000](http://localhost:8000)
16
+
17
+
## Documentation Structure
18
+
19
+
The documentation is organized as follows:
20
+
21
+
-`index.md`: Home page
22
+
-`getting-started/`: Installation and quickstart guides
23
+
-`usage/`: Core concepts and usage examples
24
+
-`sql-syntax/`: Detailed SQL syntax reference
25
+
-`debugging/`: Troubleshooting and limitations
26
+
-`licenses/`: License information
27
+
-`assets/`: Images and other static assets
28
+
-`stylesheets/`: Custom CSS styles
29
+
30
+
## Contributing to the Documentation
31
+
32
+
We welcome contributions to improve the documentation. Follow these steps:
33
+
34
+
1. Make your changes to the Markdown files in this directory
35
+
2. Run `npm run docs:serve` to preview your changes locally
36
+
3. Once you're satisfied, submit a pull request with your changes
37
+
38
+
## Building the Documentation
39
+
40
+
To build a static version of the documentation:
41
+
42
+
```bash
43
+
npm run docs:build
44
+
```
45
+
46
+
This will generate a `site` directory containing the static HTML, CSS, and JavaScript files.
47
+
48
+
## Deploying the Documentation
49
+
50
+
To deploy the documentation to GitHub Pages:
51
+
52
+
```bash
53
+
npm run docs:deploy
54
+
```
55
+
56
+
This will build the documentation and deploy it to the `gh-pages` branch of the repository.
57
+
58
+
## Documentation Technology
59
+
60
+
-[MkDocs](https://www.mkdocs.org/): The documentation site generator
61
+
-[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/): The theme for the documentation
62
+
-[Python-Markdown](https://python-markdown.github.io/): The Markdown parser
63
+
-[PyMdown Extensions](https://facelessuser.github.io/pymdown-extensions/): Extensions for Python-Markdown
64
+
65
+
## Local Development Setup
66
+
67
+
To set up the documentation development environment:
68
+
69
+
1. Install Python 3.x
70
+
2. Install MkDocs and all required packages using the requirements.txt file:
71
+
```bash
72
+
pip install -r ../requirements.txt
73
+
```
74
+
75
+
## Documentation Guidelines
76
+
77
+
When contributing to the documentation, please follow these guidelines:
78
+
79
+
1. Use clear, concise language
80
+
2. Include code examples where appropriate
81
+
3. Follow the existing structure and formatting
82
+
4. Test your changes locally before submitting
83
+
5. Use proper Markdown syntax and formatting
84
+
6. Include screenshots or diagrams for complex concepts when helpful
85
+
86
+
## License
87
+
88
+
The documentation is licensed under the same terms as the QueryLeaf project.
0 commit comments