Commit 34a84516 authored by soheib's avatar soheib
Browse files

add updated schemas

parent 068c60b1
......@@ -6,11 +6,6 @@ import { GetUserScore } from './dto/get-user-score';
export class AppController {
constructor(private readonly appService: AppService) {}
// @Get('get-comments')
// async getCommentsFromIG() {
// return await this.appService.getComments();
// }
@Get('get-followers')
async getFollowers() {
return await this.appService.getFollowers();
......@@ -50,4 +45,11 @@ export class AppController {
async getResultDb() {
return await this.appService.getResultDb();
}
// depricate code
// @Get('get-comments')
// async getCommentsFromIG() {
// return await this.appService.getComments();
// }
}
import { Module, OnApplicationBootstrap } from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import { AccountFollowersSchema } from './account.followers';
import { FollowerSchema } from './models/follower.schema';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CommentSchema } from './comment.schema';
import { LottoryResultSchema } from './LottoryResult.schema';
import { RequestSchema } from './request.schema';
import { ResultSchema } from './result.schema';
import { CommentSchema } from './models/comment.schema';
import { LottoryResultSchema } from './models/LottoryResult.schema';
import { RequestSchema } from './models/request.schema';
import { ResultSchema } from './models/result.schema';
import { PostSchema } from './models/post.schema';
@Module({
imports: [
......@@ -20,7 +21,10 @@ import { ResultSchema } from './result.schema';
{ name: 'LottoryResult', schema: LottoryResultSchema },
]),
MongooseModule.forFeature([
{ name: 'AccountFollower', schema: AccountFollowersSchema },
{ name: 'Follower', schema: FollowerSchema },
]),
MongooseModule.forFeature([
{ name: 'Post', schema: PostSchema },
]),
],
controllers: [AppController],
......
......@@ -6,20 +6,21 @@ import {
} from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model, Types } from 'mongoose';
import { CommentDocument } from './comment.schema';
import { CommentDocument } from './models/comment.schema';
import { IFollower } from './interface/Ifollower';
import { IncomingComment } from './interface/IncomingComment';
import { RequestDocument } from './request.schema';
const Instagram = require('instagram-web-api');
const { username, password } = process.env;
import * as _ from 'lodash';
import FollowerPrivateData from './followers_data';
import FollowerPrivateData from './values/followers_data';
import { CleanedComments, MentionDocument } from './interface/IcleandComment';
import { AccountFollowersDocument } from './account.followers';
import { FollowerDocument } from './models/follower.schema';
import { CommentStatus, UserAllMention } from './interface/UserAllMentions';
import { ResultDocument } from './result.schema';
import { LottoryResultDocument } from './LottoryResult.schema';
import { RequestDocument } from './models/request.schema';
import { ResultDocument } from './models/result.schema';
import { LottoryResultDocument } from './models/LottoryResult.schema';
@Injectable()
export class AppService implements OnApplicationBootstrap {
......@@ -30,8 +31,8 @@ export class AppService implements OnApplicationBootstrap {
private requestModel: Model<RequestDocument>,
@InjectModel('Comment')
private commentModel: Model<CommentDocument>,
@InjectModel('AccountFollower')
private followerModel: Model<AccountFollowersDocument>,
@InjectModel('Follower')
private followerModel: Model<FollowerDocument>,
@InjectModel('Result')
private resultModel: Model<ResultDocument>,
@InjectModel('LottoryResult')
......@@ -283,8 +284,8 @@ export class AppService implements OnApplicationBootstrap {
allUserMentions.push(newMentionData);
} else {
newMentionData.mentioned_username = foundAccount.username;
newMentionData.mentioned_user_id = foundAccount.user_id;
newMentionData.mentioned_username = "foundAccount.username";
newMentionData.mentioned_user_id = "foundAccount.instagram_user_id";
newMentionData.page_follow_date = foundAccount.follow_date;
newMentionData.comment_date = mentionedUser.date;
......
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type AccountFollowersDocument = AccountFollowers & Document;
export type AccountDocument = Account & Document;
@Schema({ timestamps: true })
export class AccountFollowers {
export class Account {
@Prop()
_id: Types.ObjectId;
_id: Types.ObjectId
@Prop()
username: string;
username: string
@Prop()
user_id: string;
instagram_user_id: string
@Prop()
full_name: string;
@Prop()
bussines_username: string;
@Prop({ type: Object })
follower_obejct: Object;
@Prop()
follow_date: number;
full_name: string
}
export const AccountFollowersSchema =
SchemaFactory.createForClass(AccountFollowers);
export const AccountSchema =
SchemaFactory.createForClass(Account)
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type FollowerDocument = Follower & Document;
@Schema({ timestamps: true })
export class Follower {
@Prop()
_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Account' })
user_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Account' })
account_id: Types.ObjectId
@Prop({ type: Object })
follower_obejct: Object
@Prop()
follow_date: number
// @Prop()
// likes_count: number
// @Prop()
// comment_count: number
}
export const FollowerSchema =
SchemaFactory.createForClass(Follower)
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type LikeDocument = Like & Document;
@Schema({ timestamps: true })
export class Like {
@Prop()
_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Follower' })
follower_id: Types.ObjectId
@Prop({ type: Types.ObjectId, ref: 'Post' })
post_id: string
@Prop()
date: number
}
export const LikeSchema = SchemaFactory.createForClass(Like);
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Types } from 'mongoose';
export type PostDocument = Post & Document;
@Schema({ timestamps: true })
export class Post {
@Prop()
_id: Types.ObjectId
@Prop()
url: string
@Prop()
instagram_id: string
}
export const PostSchema =
SchemaFactory.createForClass(Post)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment