refactor: Move reset logic to connection model
This commit is contained in:
@@ -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);
|
||||||
};
|
};
|
||||||
|
@@ -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;
|
||||||
|
Reference in New Issue
Block a user