mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-08-27 02:54:31 -05:00
added CommunityData type
This commit is contained in:
@@ -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'
|
||||
};
|
||||
|
||||
10
src/types/miiverse/community.ts
Normal file
10
src/types/miiverse/community.ts
Normal 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;
|
||||
};
|
||||
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user