mirror of
https://github.com/hexolan/panels.git
synced 2026-03-27 04:44:10 +00:00
init user-service
This commit is contained in:
25
services/user-service/src/mongo/User.ts
Normal file
25
services/user-service/src/mongo/User.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Document, Schema, model } from "mongoose";
|
||||
import uniqueValidator from "mongoose-unique-validator";
|
||||
|
||||
const userSchema = new Schema(
|
||||
{
|
||||
username: { type: String, required: true, lowercase: true, unique: true },
|
||||
isAdmin: { type: Boolean, required: false, default: false }
|
||||
},
|
||||
{
|
||||
timestamps: true
|
||||
}
|
||||
);
|
||||
|
||||
userSchema.plugin(uniqueValidator);
|
||||
|
||||
interface IUser extends Document {
|
||||
username: string;
|
||||
isAdmin?: boolean;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
const User = model<IUser>("User", userSchema);
|
||||
|
||||
export { User, IUser }
|
||||
Reference in New Issue
Block a user