-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): #21 added hublot service schemas definition
- Loading branch information
Showing
4 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
72
server/src/modules/hublots/schema/hublot-package-item.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
64
server/src/modules/hublots/schema/hublot-package.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |