first commit
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { model, Schema } from "mongoose";
|
||||
|
||||
const buildSchema = new Schema(
|
||||
{
|
||||
companyId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
sessionLimit: {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
toJSON: { virtuals: true },
|
||||
toObject: { virtuals: true },
|
||||
}
|
||||
);
|
||||
|
||||
buildSchema.virtual("scheduledSessions", {
|
||||
ref: "Scheduled_Session",
|
||||
localField: "_id",
|
||||
foreignField: "buildId",
|
||||
});
|
||||
|
||||
const Build = model("Build", buildSchema);
|
||||
|
||||
export default Build;
|
||||
@@ -0,0 +1,38 @@
|
||||
import { model, Schema } from "mongoose";
|
||||
|
||||
const companySchema = new Schema(
|
||||
{
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
toJSON: { virtuals: true },
|
||||
toObject: { virtuals: true },
|
||||
}
|
||||
);
|
||||
|
||||
companySchema.virtual("users", {
|
||||
ref: "User",
|
||||
localField: "_id",
|
||||
foreignField: "companyId",
|
||||
});
|
||||
|
||||
companySchema.virtual("scheduledSessions", {
|
||||
ref: "Scheduled_Session",
|
||||
localField: "_id",
|
||||
foreignField: "companyId",
|
||||
});
|
||||
|
||||
companySchema.virtual("builds", {
|
||||
ref: "Build",
|
||||
localField: "_id",
|
||||
foreignField: "companyId",
|
||||
});
|
||||
|
||||
const Company = model("Company", companySchema);
|
||||
|
||||
export default Company;
|
||||
@@ -0,0 +1,45 @@
|
||||
import { model, Schema } from "mongoose";
|
||||
|
||||
const scheduledSessionSchema = new Schema(
|
||||
{
|
||||
companyId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "Company",
|
||||
required: true,
|
||||
},
|
||||
buildId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "Build",
|
||||
required: true,
|
||||
},
|
||||
userId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "User",
|
||||
},
|
||||
startAt: {
|
||||
type: Date,
|
||||
required: true,
|
||||
},
|
||||
clientName: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
clientPhone: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
clientEmail: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
toJSON: { virtuals: true },
|
||||
toObject: { virtuals: true },
|
||||
}
|
||||
);
|
||||
|
||||
const ScheduledSession = model("Scheduled_Session", scheduledSessionSchema);
|
||||
|
||||
export default ScheduledSession;
|
||||
@@ -0,0 +1,24 @@
|
||||
import { model, Schema } from "mongoose";
|
||||
|
||||
const tokenSchema = new Schema(
|
||||
{
|
||||
userId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "User",
|
||||
required: true,
|
||||
},
|
||||
accessToken: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
toJSON: { virtuals: true },
|
||||
toObject: { virtuals: true },
|
||||
}
|
||||
);
|
||||
|
||||
const Token = model("Token", tokenSchema);
|
||||
|
||||
export default Token;
|
||||
@@ -0,0 +1,40 @@
|
||||
import { model, Schema } from "mongoose";
|
||||
|
||||
const userSchema = new Schema(
|
||||
{
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
companyId: {
|
||||
type: Schema.Types.ObjectId,
|
||||
ref: "Company",
|
||||
required: true,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
role: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
avatar: {
|
||||
type: String,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
toJSON: { virtuals: true },
|
||||
toObject: { virtuals: true },
|
||||
}
|
||||
);
|
||||
|
||||
const User = model("User", userSchema);
|
||||
|
||||
export default User;
|
||||
Reference in New Issue
Block a user