refactor: Move reset logic to connection model

This commit is contained in:
Faruk AYDIN
2024-09-15 01:03:17 +03:00
parent 1009c71e72
commit b0abf94191
2 changed files with 13 additions and 5 deletions

View File

@@ -8,11 +8,7 @@ export default async (request, response) => {
})
.throwIfNotFound();
connection = await connection.$query().patchAndFetch({
formattedData: connection?.formattedData?.screenName
? { screenName: connection.formattedData.screenName }
: null,
});
connection = await connection.reset();
renderObject(response, connection);
};

View File

@@ -249,6 +249,18 @@ class Connection extends Base {
return { url };
}
async reset() {
const formattedData = this?.formattedData?.screenName
? { screenName: this.formattedData.screenName }
: null;
const updatedConnection = await this.$query().patchAndFetch({
formattedData,
});
return updatedConnection;
}
}
export default Connection;