Skip to content

Commit

Permalink
chore: fix jsdoc errors and add some examples, pt. 1. (#1264)
Browse files Browse the repository at this point in the history
  • Loading branch information
igalklebanov authored Nov 19, 2024
1 parent 25b6715 commit c2d65e0
Show file tree
Hide file tree
Showing 7 changed files with 420 additions and 75 deletions.
5 changes: 5 additions & 0 deletions deno.check.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export type PetUpdate = Updateable<PetTable>
export type Species = 'dog' | 'cat'

declare global {
// @ts-ignore
export class Buffer {
static isBuffer(obj: unknown): obj is { length: number }
static compare(a: Buffer, b: Buffer): number
}
export const db: Kysely<Database>
export function functionThatExpectsPersonWithNonNullValue(
person: Person & { nullable_column: string },
Expand Down
52 changes: 43 additions & 9 deletions src/schema/alter-table-add-index-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,23 @@ export class AlterTableAddIndexBuilder

/**
* Makes the index unique.
*
* ### Examples
*
* ```ts
* await db.schema
* .alterTable('person')
* .addIndex('person_first_name_index')
* .unique()
* .column('email')
* .execute()
* ```
*
* The generated SQL (MySQL):
*
* ```sql
* alter table `person` add unique index `person_first_name_index` (`email`)
* ```
*/
unique(): AlterTableAddIndexBuilder {
return new AlterTableAddIndexBuilder({
Expand All @@ -48,11 +65,11 @@ export class AlterTableAddIndexBuilder
*
* ```ts
* await db.schema
* .alterTable('person')
* .createIndex('person_first_name_and_age_index')
* .column('first_name')
* .column('age desc')
* .execute()
* .alterTable('person')
* .addIndex('person_first_name_and_age_index')
* .column('first_name')
* .column('age desc')
* .execute()
* ```
*
* The generated SQL (MySQL):
Expand Down Expand Up @@ -84,10 +101,10 @@ export class AlterTableAddIndexBuilder
*
* ```ts
* await db.schema
* .alterTable('person')
* .addIndex('person_first_name_and_age_index')
* .columns(['first_name', 'age desc'])
* .execute()
* .alterTable('person')
* .addIndex('person_first_name_and_age_index')
* .columns(['first_name', 'age desc'])
* .execute()
* ```
*
* The generated SQL (MySQL):
Expand Down Expand Up @@ -144,6 +161,23 @@ export class AlterTableAddIndexBuilder

/**
* Specifies the index type.
*
* ### Examples
*
* ```ts
* await db.schema
* .alterTable('person')
* .addIndex('person_first_name_index')
* .column('first_name')
* .using('hash')
* .execute()
* ```
*
* The generated SQL (MySQL):
*
* ```sql
* alter table `person` add index `person_first_name_index` (`first_name`) using hash
* ```
*/
using(indexType: IndexType): AlterTableAddIndexBuilder
using(indexType: string): AlterTableAddIndexBuilder
Expand Down
Loading

0 comments on commit c2d65e0

Please sign in to comment.