gadget/gadget-code/src/models/user.ts
Rob Colbert 9abfd08529 integrated new persona field in User
User Settings will enable User to enter a Persona, or a description of
the User, to be included in the system prompt. This helps calibrate the
agent to better assist the User, and work with the User in ways that
work best for each individual User of the system.
2026-05-08 13:07:39 -04:00

37 lines
1.2 KiB
TypeScript

// src/models/user.ts
// Copyright (C) 2026 Robert Colbert <rob.colbert@openplatform.us>
// All Rights Reserved
import { Schema, model } from "mongoose";
import { IUser, IUserFlags } from "@gadget/api";
import { nanoid } from "nanoid";
export const UserFlagsSchema = new Schema<IUserFlags>(
{
isEmailVerified: { type: Boolean, default: false, required: true },
isAdmin: { type: Boolean, default: false, required: true },
isTest: { type: Boolean, default: false, required: true },
isBanned: { type: Boolean, default: false, required: true },
},
{ _id: false },
);
export const UserSchema = new Schema<IUser>({
_id: { type: String, default: () => nanoid() },
email: { type: String, required: true },
email_lc: { type: String, required: true, lowercase: true, unique: true },
passwordSalt: { type: String, required: true, select: false },
password: { type: String, required: true, select: false },
displayName: { type: String, minlength: 3, maxlength: 30, required: true },
flags: { type: UserFlagsSchema, required: true },
persona: { type: String },
});
export const User = model<IUser>("User", UserSchema);
export default User;
(async () => {
await User.syncIndexes();
})();