-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9a9cb1
commit 33be7c8
Showing
47 changed files
with
2,130 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,62 @@ | ||
# Summary | ||
# Table of contents | ||
|
||
- [Introduction](introduction.md) | ||
- [Installation](installation.md) | ||
- Core Concepts | ||
- [Schema Definition](coreconcepts/schemas.md) | ||
- [Inisitalizing Schema](coreconcepts/initializing-the-database.md) | ||
- [Altering Schema](coreconcepts/altering-the-schema.md) | ||
- [Migrations](coreconcepts/migrations.md) | ||
- CRUD Operations | ||
- [Creating Records](coreconcepts/crud-operations/creating-records.md) | ||
- [Reading Records](coreconcepts/crud-operations/reading-records.md) | ||
- [Updating Records](coreconcepts/crud-operations/updating-records.md) | ||
- [Deleting Records](coreconcepts/crud-operations/deleting-records.md) | ||
- Patterns | ||
- [Active Record](coreconcepts/patterns/active-record.md) | ||
- [Entity Framework](coreconcepts/patterns/entity-framework.md) | ||
- [Repository](coreconcepts/patterns/repository.md) | ||
- API | ||
- [Insert](api/insert.md) | ||
- [PrimaryKeyType](api/PrimaryKeyType.md) | ||
- [ForeignKey](api/ForeignKey.md) | ||
- [Record](api/Record.md) | ||
- [Schema](api/Schema.md) | ||
- [Column](api/Column.md) | ||
- [Table](api/Table.md) | ||
- [Migration](api/Migration.md) | ||
- [Repository](api/Repository.md) | ||
- [Migrator](api/Migrator.md) | ||
- [Error](api/Error.md) | ||
- [Query](api/Query.md) | ||
- [Delete](api/Delete.md) | ||
- [Update](api/update.md) | ||
- [AlterTable](api/AlterTable.md) | ||
- [PrimaryKey](api/PrimaryKey.md) | ||
- [Adapter](api/Adapter.md) | ||
- [Relations](api/Relations.md) | ||
- [Belongs To](api/relations/BelongsTo.md) | ||
- [Has One](api/relations/HasOne.md) | ||
- [Has Many](api/relations/HasMany.md) | ||
- [Many To Many](api/relations/ManyToMany.md) | ||
- [Collection](api/relations/Collection.md) | ||
- [Many Collection](api/relations/ManyCollection.md) | ||
- Guides | ||
- Active Record | ||
- [Record Models](guides/active-record-with-api/cql-record-models.md) | ||
- [Belongs To](guides/active-record-with-api/belongsto.md) | ||
- [Has Many](guides/active-record-with-api/hasmany.md) | ||
- [Has One](guides/active-record-with-api/hasone.md) | ||
- [Many To Many](guides/active-record-with-api/manytomany.md) | ||
- [Getting Started](guides/getting-started.md) | ||
- [Complex Queries](guides/complex-queries.md) | ||
- [Transaction Management](guides/transaction-management.md) | ||
- [Handling Migrations](guides/handling-migrations.md) | ||
- [Troubleshooting](guides/troubleshooting.md) | ||
- [FAQs](guides/faqs.md) | ||
* [README](README.md) | ||
* [Introduction](introduction.md) | ||
* [Installation](installation.md) | ||
* [Core Concepts](core-concepts/README.md) | ||
* [Schema Definition](coreconcepts/schemas.md) | ||
* [Inisitalizing Schema](coreconcepts/initializing-the-database.md) | ||
* [Altering Schema](coreconcepts/altering-the-schema.md) | ||
* [Migrations](coreconcepts/migrations.md) | ||
* [CRUD Operations](core-concepts/crud-operations/README.md) | ||
* [Creating Records](coreconcepts/crud-operations/creating-records.md) | ||
* [Reading Records](coreconcepts/crud-operations/reading-records.md) | ||
* [Updating Records](coreconcepts/crud-operations/updating-records.md) | ||
* [Deleting Records](coreconcepts/crud-operations/deleting-records.md) | ||
* [Patterns](core-concepts/patterns/README.md) | ||
* [Active Record](coreconcepts/patterns/active-record.md) | ||
* [Entity Framework](coreconcepts/patterns/entity-framework.md) | ||
* [Repository](coreconcepts/patterns/repository.md) | ||
* [API](api/README.md) | ||
* [enum CQL::Adapter](api/enum-cql-adapter.md) | ||
* [class CQL::AlterTable](api/class-cql-altertable.md) | ||
* [class CQL::Column(T)](api/class-cql-column-t.md) | ||
* [class CQL::Delete](api/class-cql-delete.md) | ||
* [class CQL::Error](api/class-cql-error.md) | ||
* [class CQL::ForeignKey](api/class-cql-foreignkey.md) | ||
* [class CQL::Insert](api/class-cql-insert.md) | ||
* [class CQL::Migration](api/class-cql-migration/README.md) | ||
* [MigrationRecord](api/class-cql-migration/migrationrecord.md) | ||
* [Migrator](api/class-cql-migration/migrator.md) | ||
* [class CQL::Migrator](api/class-cql-migrator.md) | ||
* [class CQL::PrimaryKey(T)](api/class-cql-primarykey-t.md) | ||
* [alias CQL::PrimaryKeyType](api/alias-cql-primarykeytype.md) | ||
* [class CQL::Query](api/class-cql-query.md) | ||
* [CQL API](api/cql-api.md) | ||
* [module CQL::Record(T, Pk)](api/module-cql-record-t-pk.md) | ||
* [module CQL::Relations](api/module-cql-relations/README.md) | ||
* [module CQL::Relations::BelongsTo](api/module-cql-relations/module-cql-relations-belongsto.md) | ||
* [class CQL::Relations::Collection(Target, Pk)](api/module-cql-relations/class-cql-relations-collection-target-pk.md) | ||
* [module CQL::Relations::HasMany](api/module-cql-relations/module-cql-relations-hasmany.md) | ||
* [module CQL::Relations::HasOne](api/module-cql-relations/module-cql-relations-hasone.md) | ||
* [module CQL::Relations::ManyToMany](api/module-cql-relations/module-cql-relations-manytomany.md) | ||
* [class CQL::Relations::ManyCollection(Target, Through, Pk)](api/module-cql-relations/class-cql-relations-manycollection-target-through-pk.md) | ||
* [Relations](api/module-cql-relations/relations.md) | ||
* [class CQL::Repository(T, Pk)](api/class-cql-repository-t-pk.md) | ||
* [Schema](api/schema.md) | ||
* [class CQL::Table](api/class-cql-table.md) | ||
* [class CQL::Update](api/class-cql-update.md) | ||
* [class CQL::Index](api/class-cql-index.md) | ||
* [Guides](guides/README.md) | ||
* [Active Record](guides/active-record/README.md) | ||
* [Record Models](guides/active-record/record-models.md) | ||
* [Belongs To](guides/active-record/belongs-to.md) | ||
* [Has Many](guides/active-record/has-many.md) | ||
* [Has One](guides/active-record/has-one.md) | ||
* [Many To Many](guides/active-record/many-to-many.md) | ||
* [Getting Started](guides/getting-started.md) | ||
* [Complex Queries](guides/complex-queries.md) | ||
* [Transaction Management](guides/transaction-management.md) | ||
* [Handling Migrations](guides/handling-migrations.md) | ||
* [Troubleshooting](troubleshooting.md) | ||
* [FAQs](faqs.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# API | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# alias CQL::PrimaryKeyType | ||
|
||
The `CQL::PrimaryKeyType` alias represents the type of a primary key column in a database schema. Primary keys can be of various types, such as `Int32`, `Int64`, or other unique identifiers. | ||
|
||
## Example: Defining a Primary Key with PrimaryKeyType | ||
|
||
```crystal | ||
schema.define do | ||
table :users do | ||
primary :id, CQL::PrimaryKeyType | ||
column :name, String | ||
end | ||
end | ||
``` | ||
|
||
### Supported Types | ||
|
||
* **Int32**: Represents a 32-bit integer primary key. | ||
* **Int64**: Represents a 64-bit integer primary key. | ||
* **UUID**: Represents a Universally Unique Identifier (if supported by the database). | ||
|
||
**Example**: | ||
|
||
```crystal | ||
primary :id, Int64, auto_increment: true | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# class CQL::AlterTable | ||
|
||
`Reference` < `Object` | ||
|
||
The `CQL::AlterTable` class is responsible for handling alterations to the database schema. It allows you to add, drop, rename, and change columns in a table. | ||
|
||
## Example: Altering a Table | ||
|
||
```crystal | ||
alter_table = AlterTable.new | ||
alter_table.add_column(:email, "string") | ||
alter_table.drop_column(:age) | ||
alter_table.rename_column(:email, :user_email) | ||
alter_table.change_column(:age, "string") | ||
``` | ||
|
||
## Constructors | ||
|
||
### def new | ||
|
||
Creates a new `AlterTable` object. | ||
|
||
* **@return** \[AlterTable] The new alter table object. | ||
|
||
## Methods | ||
|
||
### def add\_column(column : Symbol, type : String) | ||
|
||
Adds a new column to the table. | ||
|
||
* **@param** column \[Symbol] The name of the column to add. | ||
* **@param** type \[String] The data type of the new column. | ||
* **@return** \[AlterTable] The updated alter table object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
alter_table.add_column(:email, "string") | ||
``` | ||
|
||
### def drop\_column(column : Symbol) | ||
|
||
Drops a column from the table. | ||
|
||
* **@param** column \[Symbol] The name of the column to drop. | ||
* **@return** \[AlterTable] The updated alter table object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
alter_table.drop_column(:age) | ||
``` | ||
|
||
### def rename\_column(old\_name : Symbol, new\_name : Symbol) | ||
|
||
Renames a column in the table. | ||
|
||
* **@param** old\_name \[Symbol] The current name of the column. | ||
* **@param** new\_name \[Symbol] The new name for the column. | ||
* **@return** \[AlterTable] The updated alter table object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
alter_table.rename_column(:email, :user_email) | ||
``` | ||
|
||
### def change\_column(column : Symbol, new\_type : String) | ||
|
||
Changes the data type of a column. | ||
|
||
* **@param** column \[Symbol] The name of the column to change. | ||
* **@param** new\_type \[String] The new data type for the column. | ||
* **@return** \[AlterTable] The updated alter table object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
alter_table.change_column(:age, "string") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# class CQL::Column(T) | ||
|
||
`CQL::BaseColumn` < `Reference` < `Object` | ||
|
||
The `CQL::Column` class represents a column in a table. It provides methods for defining the column type, setting default values, and applying constraints such as `NOT NULL` or `UNIQUE`. | ||
|
||
## Example: Creating a Column | ||
|
||
```crystal | ||
schema.define do | ||
table :users do | ||
column :name, String, null: false, default: "John" | ||
column :age, Int32, null: false | ||
end | ||
end | ||
``` | ||
|
||
## Constructors | ||
|
||
### def new(name : Symbol, type : Type, options : Hash = {}) | ||
|
||
Creates a new column with the specified name, type, and options. | ||
|
||
* **@param** name \[Symbol] The name of the column. | ||
* **@param** type \[Type] The data type of the column. | ||
* **@param** options \[Hash] Additional options for the column (e.g., `null`, `default`, `unique`). | ||
* **@return** \[Column] The created column object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
column = CQL::Column.new(:name, String, null: false, default: "John") | ||
``` | ||
|
||
## Methods | ||
|
||
### def null | ||
|
||
Specifies whether the column allows `NULL` values. | ||
|
||
* **@return** \[Bool] `true` if the column allows null values, `false` otherwise. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
column.null(false) | ||
``` | ||
|
||
### def default(value : DB::Any) | ||
|
||
Sets the default value for the column. | ||
|
||
* **@param** value \[DB::Any] The default value for the column. | ||
* **@return** \[Column] The updated column object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
column.default("John") | ||
``` | ||
|
||
### def unique | ||
|
||
Specifies whether the column should have a `UNIQUE` constraint. | ||
|
||
* **@return** \[Column] The updated column object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
column.unique(true) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# class CQL::Delete | ||
|
||
`Reference` < `Object` | ||
|
||
The `CQL::Delete` class represents a SQL `DELETE` query. It provides methods to construct and execute delete queries. | ||
|
||
## Example: Deleting a Record | ||
|
||
```crystal | ||
delete.from(:users).where(id: 1).commit | ||
``` | ||
|
||
## Constructors | ||
|
||
### def new(schema : Schema) | ||
|
||
Initializes a new delete query. | ||
|
||
* **@param** schema \[Schema] The schema to use. | ||
* **@return** \[Delete] The delete query object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
delete = CQL::Delete.new(schema) | ||
``` | ||
|
||
## Methods | ||
|
||
### def from(table : Symbol) | ||
|
||
Specifies the table to delete from. | ||
|
||
* **@param** table \[Symbol] The name of the table. | ||
* **@return** \[Delete] The delete query object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
delete.from(:users) | ||
``` | ||
|
||
### def where(conditions : Hash(Symbol, DB::Any)) | ||
|
||
Adds a `WHERE` clause to the delete query. | ||
|
||
* **@param** conditions \[Hash(Symbol, DB::Any)] A hash of conditions for the delete operation. | ||
* **@return** \[Delete] The delete query object. | ||
|
||
**Example**: | ||
|
||
```crystal | ||
delete.where(id: 1) | ||
``` | ||
|
||
### def commit | ||
|
||
Executes the delete query. | ||
|
||
* **@return** \[Nil] | ||
|
||
**Example**: | ||
|
||
```crystal | ||
delete.from(:users).where(id: 1).commit | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# class CQL::Error | ||
|
||
`Exception` < `Reference` < `Object` | ||
|
||
Error class This class represents an error in the CQL library It provides a message describing the error | ||
|
||
**Example** Raising an error | ||
|
||
```crystal | ||
raise CQL::Error.new("Something went wrong") | ||
``` | ||
|
||
## Constructors | ||
|
||
### def new`(message : String)` |
Oops, something went wrong.