2025-04-18 11:16:43 -07:00
|
|
|
import { IDatabaseAccountJson, IIgnore } from "@/src/types/loginTypes";
|
2023-05-23 20:53:26 -04:00
|
|
|
import { model, Schema, SchemaOptions } from "mongoose";
|
|
|
|
|
2023-05-19 15:22:48 -03:00
|
|
|
const opts = {
|
2023-05-23 20:42:06 -04:00
|
|
|
toJSON: { virtuals: true },
|
|
|
|
toObject: { virtuals: true }
|
2023-05-19 15:22:48 -03:00
|
|
|
} satisfies SchemaOptions;
|
|
|
|
|
2024-12-23 00:40:35 +01:00
|
|
|
const databaseAccountSchema = new Schema<IDatabaseAccountJson>(
|
2023-05-23 20:42:06 -04:00
|
|
|
{
|
|
|
|
email: { type: String, required: true, unique: true },
|
|
|
|
password: { type: String, required: true },
|
2024-12-23 22:44:01 +01:00
|
|
|
DisplayName: { type: String, required: true, unique: true },
|
2023-05-23 20:42:06 -04:00
|
|
|
CountryCode: { type: String, required: true },
|
|
|
|
ClientType: { type: String },
|
|
|
|
CrossPlatformAllowed: { type: Boolean, required: true },
|
|
|
|
ForceLogoutVersion: { type: Number, required: true },
|
|
|
|
AmazonAuthToken: { type: String },
|
|
|
|
AmazonRefreshToken: { type: String },
|
|
|
|
ConsentNeeded: { type: Boolean, required: true },
|
2024-05-28 13:45:06 +02:00
|
|
|
TrackedSettings: { type: [String], default: [] },
|
2024-12-22 00:44:49 +01:00
|
|
|
Nonce: { type: Number, default: 0 },
|
2025-05-01 13:53:10 -07:00
|
|
|
BuildLabel: String,
|
2025-03-09 07:40:37 -07:00
|
|
|
Dropped: Boolean,
|
2025-03-21 05:19:42 -07:00
|
|
|
LatestEventMessageDate: { type: Date, default: 0 },
|
|
|
|
LastLoginRewardDate: { type: Number, default: 0 },
|
2025-03-25 15:11:26 -07:00
|
|
|
LoginDays: { type: Number, default: 1 }
|
2023-05-23 20:42:06 -04:00
|
|
|
},
|
|
|
|
opts
|
2023-05-19 15:22:48 -03:00
|
|
|
);
|
|
|
|
|
|
|
|
databaseAccountSchema.set("toJSON", {
|
2023-05-23 20:42:06 -04:00
|
|
|
transform(_document, returnedObject) {
|
|
|
|
delete returnedObject._id;
|
|
|
|
delete returnedObject.__v;
|
|
|
|
},
|
|
|
|
virtuals: true
|
2023-05-19 15:22:48 -03:00
|
|
|
});
|
|
|
|
|
2024-12-23 00:40:35 +01:00
|
|
|
export const Account = model<IDatabaseAccountJson>("Account", databaseAccountSchema);
|
2025-04-18 11:16:43 -07:00
|
|
|
|
|
|
|
const ignoreSchema = new Schema<IIgnore>({
|
|
|
|
ignorer: Schema.Types.ObjectId,
|
|
|
|
ignoree: Schema.Types.ObjectId
|
|
|
|
});
|
|
|
|
|
|
|
|
ignoreSchema.index({ ignorer: 1 });
|
|
|
|
ignoreSchema.index({ ignorer: 1, ignoree: 1 }, { unique: true });
|
|
|
|
|
|
|
|
export const Ignore = model<IIgnore>("Ignore", ignoreSchema);
|