Skip to content

Commit cd426ba

Browse files
committed
refactor: instance method naming convention
1 parent 022d907 commit cd426ba

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/mixins/Model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default function Model(
8282
/**
8383
* Determine if the instance has been trashed.
8484
*/
85-
model.prototype.trashed = function() {
85+
model.prototype.$trashed = function() {
8686
const { flagName } = context.createConfig(this.$self().softDeleteConfig)
8787

8888
return this[flagName] === true

src/mixins/Query.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export default function Query(
9393
}
9494

9595
/**
96-
* Fetch all trashed records from the store
96+
* Fetch all trashed records from the store.
9797
*/
9898
query.prototype.allTrashed = function() {
9999
return this.onlyTrashed().get()
@@ -121,18 +121,18 @@ export default function Query(
121121
models: Data.Collection
122122
) {
123123
return models.filter((model) => {
124-
// Only trashed records.
124+
// Only trashed records
125125
if (this.softDeletesFilter === true) {
126-
return model.trashed()
126+
return model.$trashed()
127127
}
128128

129-
// Include trashed records.
129+
// Include trashed records
130130
if (this.softDeletesFilter === false) {
131131
return models
132132
}
133133

134-
// Exclude trashed records.
135-
return !model.trashed()
134+
// Exclude trashed records
135+
return !model.$trashed()
136136
})
137137
})
138138
}

src/types/vuex-orm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare module '@vuex-orm/core' {
4343
/**
4444
* Determine if the instance has been trashed.
4545
*/
46-
trashed(): boolean
46+
$trashed(): boolean
4747
}
4848

4949
namespace Query {

test/feature/model/Retrieve.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ describe('Feature - Model - Retrieve', () => {
8181
await User.softDelete(1)
8282

8383
const users = User.query()
84-
.where((user: User) => user.trashed())
84+
.where((user: User) => user.$trashed())
8585
.get()
8686

8787
expect(users.length).toBe(0)
@@ -116,7 +116,7 @@ describe('Feature - Model - Retrieve', () => {
116116
.get()
117117

118118
expect(users.length).toBe(2)
119-
expect(users[0].trashed()).toBe(true)
120-
expect(users[1].trashed()).toBe(false)
119+
expect(users[0].$trashed()).toBe(true)
120+
expect(users[1].$trashed()).toBe(false)
121121
})
122122
})

0 commit comments

Comments
 (0)