Skip to content

Commit

Permalink
Clean up markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasjpr committed Aug 18, 2024
1 parent e81627b commit b9aad6b
Show file tree
Hide file tree
Showing 26 changed files with 318 additions and 1,109 deletions.
36 changes: 3 additions & 33 deletions docs/Cql/Adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
title: "Cql::Adapter"
---

::: v-pre
# enum Cql::Adapter

`Enum` < `Comparable` < `Value` < `Object`

Represents a database adapter module.
::: details Table of Contents
details Table of Contents
[[toc]]
:::



## Constants

Expand All @@ -21,60 +18,33 @@ Represents a database adapter module.
0
```



### MySql

```crystal
1
```



### Postgres

```crystal
2
```





## Instance Methods


### def my_sql?






### def postgres?






### def sql_type`(type) : String`

Returns the SQL type for the given type.
@param type [Type] the type
@return [String] the SQL type
**Example** Getting the SQL type

```crystal
Cql::Adapter::Sqlite.sql_type(Int32) # => "INTEGER"
```




### def sqlite?





:::
79 changes: 25 additions & 54 deletions docs/Cql/AlterTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: "Cql::AlterTable"
---

::: v-pre
# class Cql::AlterTable

`Reference` < `Object`

This module is part of the Cql namespace and is responsible for handling
Expand All @@ -20,24 +20,16 @@ alter_table.change_column(:age, "string")
=> #<AlterTable:0x00007f8e7a4e1e80>
```
::: details Table of Contents
[[toc]]
:::


details Table of Contents
[[toc]]

## Constructors


### def new`(table : Cql::Table, schema : Cql::Schema)`





## Instance Methods


### def add_column`(name : Symbol, type : Any, as as_name : String | Nil = nil, null : Bool = true, default : DB::Any = nil, unique : Bool = false, size : Int32 | Nil = nil, index : Bool = false)`

Adds a new column to the table.
Expand All @@ -51,34 +43,31 @@ Adds a new column to the table.
- **@param** size [Int32, nil] the size of the column (default: nil)
- **@param** index [Bool] whether the column should be indexed (default: false)

**Example** Adding a new column with default options
**Example** Adding a new column with default options

```crystal
add_column(:email, "string")
```

**Example** Adding a new column with custom options
**Example** Adding a new column with custom options

```crystal
add_column(:age, "integer", null: false, default: "18")
```




### def change_column`(name : Symbol, type : Any)`

Changes the type of a column in the table.

- **@param** name [Symbol] the name of the column to be changed
- **@param** type [Any] the new data type for the column

**Example** Changing the type of a column
**Example** Changing the type of a column

```crystal
change_column(:age, "string")
```




### def create_index`(name : Symbol, columns : Array(Symbol), unique : Bool = false)`

Creates an index on the table.
Expand All @@ -87,56 +76,48 @@ Creates an index on the table.
- **@param** columns [Array(Symbol)] the columns to be indexed
- **@param** unique [Bool] whether the index should be unique (default: false)

**Example** Creating an index
**Example** Creating an index

```crystal
create_index(:index_users_on_email, [:email], unique: true)
```




### def drop_column`(column : Symbol)`

Drops a column from the table.

- **@param** column [Symbol] the name of the column to be dropped

**Example** Dropping a column
**Example** Dropping a column

```crystal
drop_column(:age)
```




### def drop_foreign_key`(name : Symbol)`

Drops a foreign key from the table.

- **@param** name [Symbol] the name of the foreign key to be dropped

**Example** Dropping a foreign key
**Example** Dropping a foreign key

```crystal
drop_foreign_key(:fk_user_id)
```




### def drop_index`(name : Symbol)`

Drops an index from the table.

- **@param** name [Symbol] the name of the index to be dropped

**Example** Dropping an index
**Example** Dropping an index

```crystal
drop_index(:index_users_on_email)
```




### def foreign_key`(name : Symbol, columns : Array(Symbol), table : Symbol, references : Array(Symbol), on_delete : String = "NO ACTION", on_update : String = "NO ACTION")`

Adds a foreign key to the table.
Expand All @@ -148,56 +129,46 @@ Adds a foreign key to the table.
- **@param** on_delete [String] the action on delete (default: "NO ACTION")
- **@param** on_update [String] the action on update (default: "NO ACTION")

**Example** Adding a foreign key
**Example** Adding a foreign key

```crystal
foreign_key(:fk_user_id, [:user_id], :users, [:id], on_delete: "CASCADE")
```




### 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

**Example** Renaming a column
**Example** Renaming a column

```crystal
rename_column(:email, :user_email)
````
```

### def rename_table`(new_name : Symbol)`

Renames the table.

- **@param** new_name [Symbol] the new name for the table

**Example** Renaming the table
**Example** Renaming the table

```crystal
rename_table(:new_table_name)
```




### def to_sql`(visitor : Expression::Visitor)`

Converts the alter table actions to SQL.

- **@param** visitor [Expression::Visitor] the visitor to generate SQL
- **@return** [String] the generated SQL

**Example** Generating SQL for alter table actions
**Example** Generating SQL for alter table actions

```crystal
sql = to_sql(visitor)
```



:::
22 changes: 6 additions & 16 deletions docs/Cql/Column.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
title: "Cql::Column(T)"
---

::: v-pre
# class Cql::Column(T)

`Cql::BaseColumn` < `Reference` < `Object`

A column in a table
Expand All @@ -21,18 +21,16 @@ schema.build do
end
end
```
::: details Table of Contents
[[toc]]
:::


details Table of Contents
[[toc]]

## Constructors


### def new`(name : Symbol, type : T.class, as_name : String | Nil = nil, null : Bool = false, default : DB::Any = nil, unique : Bool = false, size : Int32 | Nil = nil, index : Index | Nil = nil)`

Create a new column instance

- **@param** : name (Symbol) - The name of the column
- **@param** : type (Any) - The data type of the column
- **@param** : as_name (String, nil) - An optional alias for the column
Expand All @@ -50,14 +48,12 @@ Create a new column instance
column = Cql::Column.new(:name, String)
```



## Instance Methods


### def expression

Expressions for this column

- **@return** [Expression::ColumnBuilder] the column expression builder

**Example**
Expand All @@ -67,12 +63,10 @@ column = Cql::Column.new(:name, String)
column.expression.eq("John")
```




### def validate!`(value)`

Validate the value

- **@param** value [DB::Any] The value to validate

**Example**
Expand All @@ -81,7 +75,3 @@ Validate the value
column = Cql::Column.new(:name, String)
column.validate!("John")
```



:::
Loading

0 comments on commit b9aad6b

Please sign in to comment.