Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding options on refresh() method (Fixing issue #649) #650

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"rules": {
"prettier/prettier": [
"error"
]
],
urishabh11 marked this conversation as resolved.
Show resolved Hide resolved
"no-shadow": "off",
"@typescript-eslint/no-shadow": ["error"]
}
}
2 changes: 1 addition & 1 deletion adonis-typings/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ declare module '@ioc:Adonis/Lucid/Model' {
merge(value: Partial<ModelAttributes<this>>, allowNonExtraProperties?: boolean): this
save(): Promise<this>
delete(): Promise<void>
refresh(): Promise<this>
refresh(options?: ModelAdapterOptions): Promise<this>
load: LucidRowPreload<this>
preload: LucidRowPreload<this>

Expand Down
4 changes: 2 additions & 2 deletions src/Orm/BaseModel/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ export class BaseModel implements LucidRow {
/**
* Reload/Refresh the model instance
*/
public async refresh() {
public async refresh(options?: ModelAdapterOptions) {
urishabh11 marked this conversation as resolved.
Show resolved Hide resolved
this.ensureIsntDeleted()
const modelConstructor = this.constructor as typeof BaseModel
const { table } = modelConstructor
Expand All @@ -1908,7 +1908,7 @@ export class BaseModel implements LucidRow {
* This will occur, when some other part of the application removes
* the row
*/
const freshModelInstance = await modelConstructor.find(this.$primaryKeyValue)
const freshModelInstance = await modelConstructor.find(this.$primaryKeyValue, options)
if (!freshModelInstance) {
throw new Exception(
[
Expand Down