Skip to content

Commit e70e32b

Browse files
committed
refactor: rename deleteAll to flush
1 parent a36efad commit e70e32b

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/connection/Connection.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ export class Connection {
8383
}
8484

8585
/**
86-
* Commit `deleteAll` mutation to the store.
86+
* Commit `flush` mutation to the store.
8787
*/
88-
deleteAll(): void {
89-
this.commit('deleteAll')
88+
flush(): void {
89+
this.commit('flush')
9090
}
9191
}

src/modules/Mutations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export interface Mutations<S extends State> extends MutationTree<S> {
77
insert(state: S, records: Elements): void
88
update(state: S, records: Elements): void
99
delete(state: S, ids: string[]): void
10-
deleteAll(state: S): void
10+
flush(state: S): void
1111
}
1212

1313
/**
@@ -49,7 +49,7 @@ function destroy(state: State, ids: string[]): void {
4949
/**
5050
* Commit `deleteAll` change to the store.
5151
*/
52-
function destroyAll(state: State): void {
52+
function flush(state: State): void {
5353
state.data = {}
5454
}
5555

@@ -58,5 +58,5 @@ export const mutations = {
5858
insert,
5959
update,
6060
delete: destroy,
61-
deleteAll: destroyAll
61+
flush
6262
}

src/query/Query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,10 @@ export class Query<M extends Model = Model> {
580580
/**
581581
* Delete all records in the store.
582582
*/
583-
async deleteAll(): Promise<Collection<M>> {
583+
async flush(): Promise<Collection<M>> {
584584
const models = this.all()
585585

586-
this.connection.deleteAll()
586+
this.connection.flush()
587587

588588
return models
589589
}

src/repository/Repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export class Repository<M extends Model> {
120120
/**
121121
* Delete all records in the store.
122122
*/
123-
deleteAll(): Promise<Collection<M>> {
124-
return this.query().deleteAll()
123+
flush(): Promise<Collection<M>> {
124+
return this.query().flush()
125125
}
126126
}

test/feature/repository/deletes_delete_all.spec.ts renamed to test/feature/repository/deletes_flush.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createStore, fillState, assertState } from 'test/Helpers'
22
import { Model, Attr, Str } from '@/index'
33

4-
describe('feature/repository/deletes_delete_all', () => {
4+
describe('feature/repository/deletes_flush', () => {
55
class User extends Model {
66
static entity = 'users'
77

@@ -20,7 +20,7 @@ describe('feature/repository/deletes_delete_all', () => {
2020
}
2121
})
2222

23-
await store.$repo(User).deleteAll()
23+
await store.$repo(User).flush()
2424

2525
assertState(store, {
2626
users: {}

0 commit comments

Comments
 (0)