Skip to content

Commit

Permalink
feat(server): #21 added hublot service schemas definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcjazz committed Apr 22, 2024
1 parent 5fd18f8 commit 7262ac9
Show file tree
Hide file tree
Showing 4 changed files with 260 additions and 0 deletions.
69 changes: 69 additions & 0 deletions server/src/modules/hublots/schema/hublot-image.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document } from "mongoose";
import { v4 as uuidv4 } from "uuid";

@Schema({
autoCreate: true,
collection: "hublot_images",
})
export class HublotImage extends Document {
@Prop({
type: String,
required: true,
default: uuidv4,
})
id: string;

@Prop({
type: String,
required: true,
index: true,
})
hublotId: string;

@Prop({
type: String,
required: true,
})
caption: string;

@Prop({
type: String,
required: true,
})
imageRef: string;

@Prop({
type: Boolean,
required: true,
})
isProfile: boolean;

@Prop({
type: Date,
required: true,
})
createdAt: Date;

@Prop({
type: String,
required: true,
index: true,
})
createdBy: string;

toJSON() {
const user = this.toObject();
user.id = user._id;
delete user._id;
delete user.__v;
return user;
}

constructor(hublotImage: HublotImage) {
super();
Object.assign(this, hublotImage);
}
}

export const HublotImageSchema = SchemaFactory.createForClass(HublotImage);
72 changes: 72 additions & 0 deletions server/src/modules/hublots/schema/hublot-package-item.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { v4 as uuidv4 } from "uuid";
import { Document } from "mongoose";

@Schema({
autoCreate: true,
collection: "hublot_package_items",
})
export class HublotPackageItem extends Document {
@Prop({
type: String,
required: true,
default: uuidv4,
unique: true,
})
id: string;

@Prop({
type: String,
required: true,
index: true,
})
hublotId: string;

@Prop({
type: String,
required: true,
index: true,
})
hublotPackageId: string;

@Prop({
type: String,
required: true,
})
value: string;

@Prop({
type: String,
required: true,
})
name: string;

@Prop({
type: Date,
required: true,
})
createdAt: Date;

@Prop({
type: String,
required: true,
index: true,
})
createdBy: string;

toJSON() {
const user = this.toObject();
user.id = user._id;
delete user._id;
delete user.__v;
return user;
}

constructor(hublotPackageItem: HublotPackageItem) {
super();
Object.assign(this, hublotPackageItem);
}
}

export const HublotPackageItemSchema =
SchemaFactory.createForClass(HublotPackageItem);
64 changes: 64 additions & 0 deletions server/src/modules/hublots/schema/hublot-package.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { v4 as uuidv4 } from "uuid";
import { Document } from "mongoose";

@Schema({
autoCreate: true,
collection: "hublot_packages",
})
export class HublotPackage extends Document {
@Prop({
type: String,
required: true,
default: uuidv4,
unique: true,
})
id: string;

@Prop({
type: String,
required: true,
index: true,
})
hublotId: string;

@Prop({
type: Number,
required: true,
})
price: number;

@Prop({
type: String,
required: true,
})
name: string;

@Prop({
type: Date,
required: true,
})
createdAt: Date;

@Prop({
type: String,
required: true,
index: true,
})
createdBy: string;

toJSON() {
const user = this.toObject();
user.id = user._id;
delete user._id;
delete user.__v;
return user;
}

constructor(hublotPackage: HublotPackage) {
super();
Object.assign(this, hublotPackage);
}
}

export const HublotPackageSchema = SchemaFactory.createForClass(HublotPackage);
55 changes: 55 additions & 0 deletions server/src/modules/hublots/schema/hublot.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
import { Document } from "mongoose";
import { v4 as uuidv4 } from "uuid";

@Schema({
autoCreate: true,
collection: "hublots",
})
export class Hublot extends Document {
@Prop({
type: String,
unique: true,
default: uuidv4,
required: true,
})
id: string;

@Prop({ type: String, required: true })
name: string;

@Prop({ type: String, required: true })
location: string;

@Prop({
type: Boolean,
default: false,
required: true,
})
isVerified: boolean;

@Prop({
type: Date,
default: new Date(),
required: true,
})
createdAt: Date;

@Prop({ type: String, required: true })
createdBy: string;

toJSON() {
const user = this.toObject();
user.id = user._id;
delete user._id;
delete user.__v;
return user;
}

constructor(hublot: Hublot) {
super();
Object.assign(this, hublot);
}
}

export const HublotSchema = SchemaFactory.createForClass(Hublot);

0 comments on commit 7262ac9

Please sign in to comment.