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(); .throwIfNotFound();
connection = await connection.$query().patchAndFetch({ connection = await connection.reset();
formattedData: connection?.formattedData?.screenName
? { screenName: connection.formattedData.screenName }
: null,
});
renderObject(response, connection); renderObject(response, connection);
}; };

View File

@@ -249,6 +249,18 @@ class Connection extends Base {
return { url }; 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; export default Connection;