Skip to content

Commit 0216d1e

Browse files
committed
refactor(service): users/auth: rename session repository methods for consistency
1 parent 7c17eef commit 0216d1e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

service/src/ingress/sessions.adapters.db.mongoose.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function SessionsMongooseRepository(conn: mongoose.Connection, collection
3737
const model = conn.model('Token', SessionSchema, collectionName)
3838
return Object.freeze({
3939
model,
40-
async findSessionByToken(token: string): Promise<Session | null> {
40+
async readSessionByToken(token: string): Promise<Session | null> {
4141
const doc = await model.findOne({ token }).lean()
4242
if (!doc) {
4343
return null
@@ -64,19 +64,19 @@ export function SessionsMongooseRepository(conn: mongoose.Connection, collection
6464
return await model.findOneAndUpdate(query, update,
6565
{ upsert: true, new: true, populate: populateSessionUserRole })
6666
},
67-
async removeSession(token: string): Promise<Session | null> {
68-
const session = await this.findSessionByToken(token)
67+
async deleteSession(token: string): Promise<Session | null> {
68+
const session = await this.readSessionByToken(token)
6969
if (!session) {
7070
return null
7171
}
7272
const removed = await this.model.deleteOne({ token })
7373
return removed.deletedCount === 1 ? session : null
7474
},
75-
async removeSessionsForUser(userId: UserId): Promise<number> {
75+
async deleteSessionsForUser(userId: UserId): Promise<number> {
7676
const { deletedCount } = await model.deleteMany({ userId: new mongoose.Types.ObjectId(userId) })
7777
return deletedCount
7878
},
79-
async removeSessionsForDevice(deviceId: string): Promise<number> {
79+
async deleteSessionsForDevice(deviceId: string): Promise<number> {
8080
const { deletedCount } = await model.deleteMany({ deviceId: new mongoose.Types.ObjectId(deviceId) })
8181
return deletedCount
8282
}

0 commit comments

Comments
 (0)