forked from adonisjs/lucid
-
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.
Merge branch 'adonisjs:21.x' into develop
- Loading branch information
Showing
16 changed files
with
926 additions
and
72 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
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
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,13 +1,12 @@ | ||
/* | ||
* @adonisjs/lucid | ||
* | ||
* (c) Harminder Virk <[email protected]> | ||
* (c) AdonisJS | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
import type { FieldContext } from '@vinejs/vine/types' | ||
import type { ApplicationService } from '@adonisjs/core/types' | ||
|
||
import { Database } from '../src/database/main.js' | ||
|
@@ -16,6 +15,7 @@ import { QueryClient } from '../src/query_client/index.js' | |
import { BaseModel } from '../src/orm/base_model/index.js' | ||
import { DatabaseTestUtils } from '../src/test_utils/database.js' | ||
import type { DatabaseConfig, DbQueryEventNode } from '../src/types/database.js' | ||
import { VineDbSearchCallback, VineDbSearchOptions } from '../src/types/vine.js' | ||
|
||
/** | ||
* Extending AdonisJS types | ||
|
@@ -39,29 +39,40 @@ declare module '@adonisjs/core/test_utils' { | |
* Extending VineJS schema types | ||
*/ | ||
declare module '@vinejs/vine' { | ||
interface VineLucidBindings { | ||
interface VineLucidBindings<ValueType> { | ||
/** | ||
* Ensure the value is unique inside the database by table and column name. | ||
* Optionally, you can define a filter to narrow down the query. | ||
*/ | ||
unique(options: VineDbSearchOptions<ValueType>): this | ||
|
||
/** | ||
* Ensure the value is unique inside the database by self | ||
* executing a query. | ||
* | ||
* - The callback must return "true", if the value is unique (does not exist). | ||
* - The callback must return "false", if the value is not unique (already exists). | ||
*/ | ||
unique(callback: (db: Database, value: string, field: FieldContext) => Promise<boolean>): this | ||
unique(callback: VineDbSearchCallback<ValueType>): this | ||
|
||
/** | ||
* Ensure the value is exists inside the database by self | ||
* Ensure the value exists inside the database by table and column name. | ||
* Optionally, you can define a filter to narrow down the query. | ||
*/ | ||
exists(options: VineDbSearchOptions<ValueType>): this | ||
|
||
/** | ||
* Ensure the value exists inside the database by self | ||
* executing a query. | ||
* | ||
* - The callback must return "false", if the value exists. | ||
* - The callback must return "true", if the value does not exist. | ||
*/ | ||
exists(callback: (db: Database, value: string, field: FieldContext) => Promise<boolean>): this | ||
exists(callback: VineDbSearchCallback<ValueType>): this | ||
} | ||
|
||
interface VineNumber extends VineLucidBindings {} | ||
|
||
interface VineString extends VineLucidBindings {} | ||
interface VineNumber extends VineLucidBindings<number> {} | ||
interface VineString extends VineLucidBindings<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
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
Oops, something went wrong.