Feature/orm add casting relations #34
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Gaman ORM Plugin
The Gaman ORM Plugin provides a lightweight Object-Relational Mapping (ORM) system for Gaman applications. It supports basic CRUD operations, automatic data type casting, and model relations through a provider-based architecture.
Features
Installation
The ORM plugin is part of the Gaman ecosystem. Ensure you have Gaman installed and include the ORM plugin in your project dependencies.
Setup
BaseModel:Usage
Basic CRUD Operations
Create
Read
Update
Delete
Data Casting
The ORM automatically casts data types based on the
castsoption in your model:intorinteger: Converts to numberfloatordouble: Converts to numberstring: Converts to stringboolorboolean: Converts to booleanjson: Parses JSON string or keeps as objectdatetime: Converts to Date objectRelations
hasMany
belongsTo
hasOne
Providers
SQLite Provider
The SQLite provider uses
sqlite3andsqlitepackages. It connects to adata.dbfile in the current directory.Example Application
Here's a complete example:
Notes
For more advanced usage, refer to the source code in
index.ts,orm.ts, andmodel/base.ts.