added CommunityData type

This commit is contained in:
Jonathan Barrow 2023-10-02 16:44:10 -04:00
parent cdeac347e0
commit 2dd582a9c0
No known key found for this signature in database
GPG Key ID: E86E9FE9049C741F
3 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import { Schema, model } from 'mongoose';
import { CommunityData } from '@/types/miiverse/community';
import { ICommunity, ICommunityMethods, CommunityModel, HydratedCommunityDocument } from '@/types/mongoose/community';
const CommunitySchema = new Schema<ICommunity, CommunityModel, ICommunityMethods>({
@ -86,14 +87,14 @@ CommunitySchema.method<HydratedCommunityDocument>('delUserFavorite', async funct
await this.save();
});
CommunitySchema.method<HydratedCommunityDocument>('json', function json(): Record<string, any> {
CommunitySchema.method<HydratedCommunityDocument>('json', function json(): CommunityData {
return {
community_id: this.community_id,
name: this.name,
description: this.description,
icon: this.icon.replace(/[^A-Za-z0-9+/=\s]/g, ''),
icon_3ds: '',
pid: this.owner || '',
pid: this.owner,
app_data: this.app_data.replace(/[^A-Za-z0-9+/=\s]/g, ''),
is_user_community: '0'
};

View File

@ -0,0 +1,10 @@
export type CommunityData = {
community_id: string;
name: string;
description: string;
icon: string;
icon_3ds: string;
pid: number;
app_data: string;
is_user_community: string;
};

View File

@ -1,4 +1,5 @@
import { Model, Types, HydratedDocument } from 'mongoose';
import { CommunityData } from '@/types/miiverse/community';
enum COMMUNITY_TYPE {
Main = 0,
@ -34,7 +35,7 @@ export interface ICommunity {
export interface ICommunityMethods {
addUserFavorite(pid: number): Promise<void>;
delUserFavorite(pid: number): Promise<void>;
json(): Record<string, any>;
json(): CommunityData;
}
interface ICommunityQueryHelpers {}