-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
eb0648f
commit 41c4d13
Showing
2 changed files
with
132 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// /* | ||
// * @adonisjs/lucid | ||
// * | ||
// * (c) Harminder Virk <virk@adonisjs.com> | ||
// * | ||
// * For the full copyright and license information, please view the LICENSE | ||
// * file that was distributed with this source code. | ||
// */ | ||
|
||
// declare module '@ioc:Adonis/Lucid/Orm' { | ||
// import { | ||
// InsertQueryBuilderContract, | ||
// DatabaseQueryBuilderContract, | ||
// } from '@ioc:Adonis/Lucid/DatabaseQueryBuilder' | ||
|
||
// import { | ||
// ModelConstructorContract as BaseModelConstructorContract, | ||
// ModelContract as BaseModelContract, | ||
// AdapterContract as BaseAdapterContract, | ||
// } from '@poppinss/data-models' | ||
|
||
// export interface OrmQueryBuilder< | ||
// Model extends ModelConstructorContract, | ||
// Result extends any, | ||
// > extends DatabaseQueryBuilderContract<Model['refs']>, ExcutableQueryBuilderContract<Result> { | ||
// } | ||
|
||
// export interface ModelConstructorContract extends BaseModelConstructorContract { | ||
// $connection?: string, | ||
// $increments: boolean, | ||
// $table: string, | ||
|
||
// refs: any, | ||
|
||
// $getSaveQuery ( | ||
// client: QueryClientContract, | ||
// action: 'insert', | ||
// ): InsertQueryBuilderContract, | ||
|
||
// $getSaveQuery ( | ||
// client: QueryClientContract, | ||
// action: 'update', | ||
// ): OrmQueryBuilder<any, any>, | ||
|
||
// $getSaveQuery ( | ||
// client: QueryClientContract, | ||
// action: 'insert' | 'update', | ||
// ): InsertQueryBuilderContract | OrmQueryBuilder<any, any>, | ||
|
||
// query (): OrmQueryBuilder<this, new () => this>, | ||
// } | ||
|
||
// export interface ModelContract extends BaseModelContract { | ||
// $getConstructor (): ModelConstructorContract, | ||
// } | ||
|
||
// export interface AdapterContract extends BaseAdapterContract { | ||
// insert (instance: ModelContract, attributes: any): Promise<void> | ||
// } | ||
// } |
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 @@ | ||
/* | ||
* @adonisjs/lucid | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
/// <reference path="../../../adonis-typings/orm.ts" /> | ||
/// <reference path="../../../adonis-typings/database.ts" /> | ||
|
||
// import { DatabaseContract } from '@ioc:Adonis/Lucid/Database' | ||
// import { AdapterContract, ModelContract } from '@ioc:Adonis/Lucid/Orm' | ||
|
||
// /** | ||
// * Adapter to execute queries for a given model. Please note that adapters | ||
// * are stateless and only one instance of adapter is used across the | ||
// * app, so make sure not to store any state. | ||
// */ | ||
// export class Adapter implements AdapterContract { | ||
// constructor (private _db: DatabaseContract) {} | ||
|
||
// public async insert (model: ModelContract, attributes: any): Promise<void> { | ||
// const modelConstructor = model.$getConstructor() | ||
|
||
// /** | ||
// * Pulling the query client for a given connection. | ||
// */ | ||
// const client = this._db.connection(modelConstructor.$connection) | ||
|
||
// * | ||
// * Letting model give us the insert query. This enables the end user | ||
// * to add some constraints to the query builder before returning | ||
// * it back to us | ||
|
||
// const query = modelConstructor.$getSaveQuery(client, 'insert') | ||
|
||
// /** | ||
// * Execute the query | ||
// */ | ||
// const result = await query.insert(attributes) | ||
|
||
// /** | ||
// * Set id when increments is true | ||
// */ | ||
// if (modelConstructor.$increments) { | ||
// model.$consumeAdapterResult({ [modelConstructor.$primaryKey]: result[0] }) | ||
// } | ||
// } | ||
|
||
// public async update (model: ModelContract, dirty: any): Promise<void> { | ||
// const modelConstructor = model.$getConstructor() | ||
|
||
// /** | ||
// * Pulling the query client for a given connection. | ||
// */ | ||
// const client = this._db.connection(modelConstructor.$connection) | ||
|
||
// /** | ||
// * Letting model give us the insert query. This enables the end user | ||
// * to add some constraints to the query builder before returning | ||
// * it back to us | ||
// */ | ||
// const query = modelConstructor.$getSaveQuery(client, 'update') | ||
|
||
// /** | ||
// * Execute the query | ||
// */ | ||
// await query.update(dirty) | ||
// } | ||
// } |