Add Ship #13
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -1,6 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Document, Types } from "mongoose";
import { Oid } from "./commonTypes";
Please use non-relative imports everywhere
@ -6,0 +8,4 @@
const accountId = _req.query.accountId;
const ship = await Ship.findOne({ ShipOwnerId: accountId });
if (!ship) {
const account = await Account.findOne({ _id: accountId });
_variableName is only used to disable the eslint warning "unused variables".
Once you use a variable, remove the _
@ -6,0 +10,4 @@
if (!ship) {
const account = await Account.findOne({ _id: accountId });
if (account) {
await createShip(account._id);
Oh I saw, you added the new ship at createAccount() already. very nice.
Then the logic for !getShip should not be needed. You can just remove all that is related to creating a new Ship here, because it should never happen that for an account there is no ship
@ -0,0 +8,4 @@
await ship.save();
} catch (error) {
if (error instanceof Error) {
throw new Error(`error creating inventory" ${error.message}`);
error creating Ship! not inventory.
@ -0,0 +1,33 @@
{
"ShipOwnerId": "removed",
this field can be removed, as we add it here:
const ship = new Ship({ ...new_ship, ShipOwnerId: accountOwnerId });