chore: add indexes for various models (#1213)
All checks were successful
Build / build (22) (push) Successful in 42s
Build / build (18) (push) Successful in 1m7s
Build Docker image / docker (push) Successful in 31s
Build / build (20) (push) Successful in 1m14s

These are looked up by the owner account id and/or assumed to exist only once per account.
No index was added for "Ships" as that does not match these critera.

Reviewed-on: #1213
This commit is contained in:
Sainan 2025-03-16 08:46:02 -07:00
parent 943edf7065
commit 6d12d90877
5 changed files with 10 additions and 0 deletions

View File

@ -138,4 +138,6 @@ messageSchema.set("toJSON", {
} }
}); });
messageSchema.index({ ownerId: 1 });
export const Inbox = model<IMessageDatabase>("Inbox", messageSchema, "inbox"); export const Inbox = model<IMessageDatabase>("Inbox", messageSchema, "inbox");

View File

@ -1443,6 +1443,8 @@ inventorySchema.set("toJSON", {
} }
}); });
inventorySchema.index({ accountOwnerId: 1 }, { unique: true });
// type overwrites for subdocuments/subdocument arrays // type overwrites for subdocuments/subdocument arrays
export type InventoryDocumentProps = { export type InventoryDocumentProps = {
FlavourItems: Types.DocumentArray<IFlavourItem>; FlavourItems: Types.DocumentArray<IFlavourItem>;

View File

@ -78,6 +78,8 @@ loadoutSchema.set("toJSON", {
} }
}); });
loadoutSchema.index({ loadoutOwnerId: 1 }, { unique: true });
//create database typefor ILoadoutConfig //create database typefor ILoadoutConfig
type loadoutDocumentProps = { type loadoutDocumentProps = {
NORMAL: Types.DocumentArray<ILoadoutConfigDatabase>; NORMAL: Types.DocumentArray<ILoadoutConfigDatabase>;

View File

@ -152,6 +152,8 @@ export const personalRoomsSchema = new Schema<IPersonalRoomsDatabase>({
TailorShop: { type: tailorShopSchema, default: tailorShopDefault } TailorShop: { type: tailorShopSchema, default: tailorShopDefault }
}); });
personalRoomsSchema.index({ personalRoomsOwnerId: 1 }, { unique: true });
export const PersonalRooms = model<IPersonalRoomsDatabase, PersonalRoomsModelType>( export const PersonalRooms = model<IPersonalRoomsDatabase, PersonalRoomsModelType>(
"PersonalRooms", "PersonalRooms",
personalRoomsSchema personalRoomsSchema

View File

@ -103,6 +103,8 @@ statsSchema.set("toJSON", {
} }
}); });
statsSchema.index({ accountOwnerId: 1 }, { unique: true });
export const Stats = model<IStatsDatabase>("Stats", statsSchema); export const Stats = model<IStatsDatabase>("Stats", statsSchema);
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types