-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
117 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,18 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; | ||
import { FolderType } from '../types/folder-type.enum'; | ||
|
||
@Schema({ collection: 'folders', timestamps: true, versionKey: false }) | ||
export class Folder { | ||
@Prop({ required: true }) | ||
userId: string; | ||
|
||
@Prop({ required: true }) | ||
name: string; | ||
|
||
@Prop({ required: true, enum: FolderType }) | ||
type: FolderType; | ||
} | ||
|
||
export type FolderDocument = HydratedDocument<Folder>; | ||
export const FolderSchema = SchemaFactory.createForClass(Folder); |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
export * from './user.schema'; | ||
export * from './folder.schema'; | ||
export * from './keyword.schema'; | ||
export * from './post.schema'; | ||
export * from './postAIClassification.schema'; |
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,11 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { Document } from 'mongoose'; | ||
|
||
@Schema({ collection: 'keywords', versionKey: false }) | ||
export class Keyword { | ||
@Prop({ required: true }) | ||
name: string; | ||
} | ||
|
||
export type KeywordDocument = Keyword & Document; | ||
export const KeywordSchema = SchemaFactory.createForClass(Keyword); |
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,33 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; | ||
|
||
@Schema({ collection: 'posts', timestamps: true, versionKey: false }) | ||
export class Post { | ||
@Prop({ required: true }) | ||
userId: string; | ||
|
||
@Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Folder' }) | ||
folderId: MongooseSchema.Types.ObjectId; | ||
|
||
@Prop({ required: true }) | ||
url: string; | ||
|
||
@Prop({ required: true }) | ||
title!: string; | ||
|
||
@Prop({ required: true }) | ||
description!: string; | ||
|
||
@Prop({ default: false }) | ||
isFavorite: boolean; | ||
|
||
@Prop({ | ||
required: false, | ||
type: MongooseSchema.Types.ObjectId, | ||
ref: 'PostAIClassification', | ||
}) | ||
aiClassificationId?: MongooseSchema.Types.ObjectId; | ||
} | ||
|
||
export type PostDocument = HydratedDocument<Post>; | ||
export const PostSchema = SchemaFactory.createForClass(Post); |
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,33 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; | ||
import { Keyword, KeywordSchema } from './keyword.schema'; | ||
|
||
@Schema({ | ||
collection: 'post_ai_classification', | ||
timestamps: true, | ||
versionKey: false, | ||
}) | ||
export class PostAIClassification { | ||
@Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Folder' }) | ||
suggestedFolderId: MongooseSchema.Types.ObjectId; | ||
|
||
@Prop({ required: true }) | ||
url: string; | ||
|
||
@Prop({ required: true }) | ||
description: string; | ||
|
||
@Prop({ required: true, type: KeywordSchema }) | ||
keywords: Keyword[]; | ||
|
||
@Prop({ type: Date }) | ||
completedAt: Date; | ||
|
||
@Prop({ type: Date }) | ||
deletedAt: Date; | ||
} | ||
|
||
export type PostAIClassificationDocument = | ||
HydratedDocument<PostAIClassification>; | ||
export const PostAIClassificationSchema = | ||
SchemaFactory.createForClass(PostAIClassification); |
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,14 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { HydratedDocument, Schema as MongooseSchema } from 'mongoose'; | ||
|
||
@Schema({ collection: 'post_keywords', versionKey: false }) | ||
export class PostKeyword { | ||
@Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Post' }) | ||
postId: MongooseSchema.Types.ObjectId; | ||
|
||
@Prop({ required: true, type: MongooseSchema.Types.ObjectId, ref: 'Keyword' }) | ||
keywordId: MongooseSchema.Types.ObjectId; | ||
} | ||
|
||
export type PostKeywordDocument = HydratedDocument<PostKeyword>; | ||
export const PostKeywordSchema = SchemaFactory.createForClass(PostKeyword); |
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,4 @@ | ||
export enum FolderType { | ||
CUSTOM = 'Custom', | ||
DEFAULT = 'Default', | ||
} |