JSON ORM ๐Ÿš€

json-orm is a Ruby gem providing a lightweight, JSON-based Object-Relational Mapping (ORM) system, primarily designed for simple data analytical applications ๐Ÿ“Š. It includes CRUD operations, transaction support, custom validations, and query chaining, ideal for small-scale projects.

๐Ÿšง Important Development Notice ๐Ÿšง

While designed for simplicity and ease of use, json-orm hasn't been optimized for file size or fully vetted for reliability as a database storage solution. It's best used in contexts where these factors are not critical.

Features โœจ

  • CRUD operations on JSON files
  • Transaction support with commit and rollback
  • Custom attribute validation
  • Query chaining for advanced data filtering
  • Basic logging for debugging
  • Thread-safe operations

Future Plans

  • [ ] Refactor logging
  • [ ] Add tests to DB class
  • [ ] Clean up better after test
  • [ ] Improve test to validate reliability
  • [ ] Add Validations class

Installation ๐Ÿ”ง

Clone the repository and include it in your Ruby project:

git clone https://github.com/your-username/jsonorm.git

Usage ๐Ÿ“˜

Basic Operations

db = JSONORM::JSONDB.new('your_data.json')
orm = JSONORM::ORM.new(db)

orm.create({name: "John Doe", email: "[email protected]"})
found_record = orm.find(1)
orm.update(1, {name: "Jane Doe"})
orm.delete(1)

Transactions

orm.begin_transaction
# Operations...
orm.commit_transaction

Custom Validations

JSONORM.register_validator(:email) do |value|
  # Validation logic...
end

Query Chaining

results = orm.where(age: 30).where(city: "Wonderland").execute

Testing with MiniTest ๐Ÿงช

Tests are located in the test directory. Run them using MiniTest to ensure reliability.

Contributing ๐Ÿค

Contributions are welcome. Please ensure to follow Ruby coding style and best practices, and write tests for new functionalities.

License

Distributed under the MIT License.