https://github.com/jessicamrbr/collql
CollQL is a Dart library inspired by MongoDB queries, designed for expressive and flexible in-memory collection manipulation and filtering.
https://github.com/jessicamrbr/collql
dart dsl library mongo query
Last synced: 2 months ago
JSON representation
CollQL is a Dart library inspired by MongoDB queries, designed for expressive and flexible in-memory collection manipulation and filtering.
- Host: GitHub
- URL: https://github.com/jessicamrbr/collql
- Owner: jessicamrbr
- License: other
- Created: 2025-04-02T19:29:26.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-19T15:13:55.000Z (12 months ago)
- Last Synced: 2025-07-19T18:32:02.728Z (12 months ago)
- Topics: dart, dsl, library, mongo, query
- Language: Dart
- Homepage: https://jessicamrbr.github.io/CollQL/
- Size: 1.61 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# CollQL
A powerful and expressive Dart library for in-memory collection querying and manipulation, inspired by MongoDB. CollQL makes it easy to filter, update, and transform your data using a familiar, fluent API—perfect for Dart and Flutter projects.
[](https://pub.dev/packages/collql)
[](https://github.com/jessicamrbr/CollQL)
# Overview
CollQL is a Dart library inspired by MongoDB queries, designed for expressive and flexible in-memory collection manipulation and filtering.
- 🔍 **Filters**: Create complex queries using logical and comparison operators.
- ✏️ **Modifiers**: Update collections and documents with MongoDB-like operations.
- 🧩 **Extensions**: Utility methods to simplify usage with Dart collections.
- 🍰 **Proxies**: Builders for fluent construction of filters and modifiers.
For a comprehensive overview of all features, examples, and API references, please see the [official documentation](https://jessicamrbr.github.io/CollQL/).
# Getting Started
```dart
import 'package:collql/collql.dart';
final List data = [
Document({'name': "john", 'age': 45}),
Document({'name': "bob", 'age': 21}),
Document({'name': "alice", 'age': 60}),
Document({'name': "ted", 'age': 10}),
];
final filter = and([
'age'.gte(18),
'age'.lte(50)
]);
final List result = CollectionQL(data).fetch(filter).toList();
assert(result.length == 2); // true
```
## Quick Guide
### Documents
These are the basic data structure in CollQL. Each document is represented by an object containing key-value pairs, similar to a map or JSON object. [[Read more](/reference/00000-manipulating)]
```dart
import 'package:collql/collql.dart';
final doc = Document({
"name": "John",
"age": 30
});
assert(doc.get('/name') == "John"); // true
doc.set('/age', 31);
assert(doc.get('/age') == 31); // true
```
### Filters
Allow you to select documents from a collection or test values based on conditions. They are inspired by MongoDB operators. [[Read more](/reference/00100-filters)]
```dart
import 'package:collql/collql.dart';
final List data = [
Document({'name': "john", 'age': 45}),
// ... //
];
final query = and([
'age'.gte(18),
'age'.lte(50)
]);
assert(query.apply(data[0]) == true); // true
```
Some operators: `eq`, `notEq`, `gt`, `gte`, `lt`, `lte`, `and`, `or`
### Modifiers
Allow you to update documents declaratively. [[Read more](/reference/00200-modifiers)]
```dart
import 'package:collql/collql.dart';
final List data = [
Document({'name': "john", 'age': 45}),
// ... //
];
final doc = Document({ "name": "john", "age": 45 });
final update = 'name'.rename('fullName');
update.apply(doc);
assert(doc.get('/name') == null); // true
assert(doc.get('/fullName') != null); // true
assert(data[0].get('/name') == doc.get('/fullName')); // true
```
Some modifiers: `get`, `set`, `unset`, `rename`, `push`, `pull`
## Credits
CollQL is inspired by [Nitrite](https://nitrite.dizitart.com/flutter-sdk/getting-started/index.html), and combines concepts from both
MongoDB and Dart's collection manipulation capabilities. It aims to provide a seamless and expressive way to work with in-memory data structures.
## License
CollQL is distributed under the MIT License, allowing you to use, modify, and distribute the library freely in your own projects. See the [LICENSE](LICENSE) file for details.