Skip to content

Commit f3520ea

Browse files
committed
Update existing model for Waifu entity with additional fields and documentation
1 parent dc02dc4 commit f3520ea

File tree

2 files changed

+176
-32
lines changed

2 files changed

+176
-32
lines changed

src/controllers/v4/images/waifu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ const getWaifu = async (req, res, next) => {
3939

4040
if (name) {
4141
const sanitizedName = _.escapeRegExp(name.trim());
42-
filter['names.en'] = { $regex: new RegExp(sanitizedName, 'i') }; // Case-insensitive regex match for English name
42+
filter['name.full'] = { $regex: new RegExp(sanitizedName, 'i') }; // Case-insensitive regex match for English name
4343
}
4444

4545
if (anime) {
4646
const sanitizedAnime = _.escapeRegExp(anime.trim());
47-
filter['from.name'] = { $regex: new RegExp(sanitizedAnime, 'i') }; // Case-insensitive regex match for anime name
47+
filter['media.nodes[0].title.userPreferred'] = { $regex: new RegExp(sanitizedAnime, 'i') }; // Case-insensitive regex match for anime name
4848
}
4949

5050
/**

src/models/schemas/Waifu.js

Lines changed: 174 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,75 +8,219 @@ const { Schema, model } = mongoose;
88
* @class WaifuSchema
99
*/
1010
const WaifuSchema = new Schema({
11+
/**
12+
* The unique identifier for the Waifu.
13+
* @type {Number}
14+
*/
1115
_id: { type: Number, required: true },
12-
names: {
16+
17+
/**
18+
* The name details of the Waifu.
19+
* @type {Object}
20+
*/
21+
name: {
1322
/**
14-
* The English name of the waifu.
23+
* The first name of the Waifu.
1524
* @type {String}
1625
*/
17-
en: { type: String, required: true },
26+
first: { type: String, required: true },
1827

1928
/**
20-
* The Japanese name of the waifu.
29+
* The middle name of the Waifu.
2130
* @type {String}
2231
*/
23-
jp: { type: String },
32+
middle: String,
2433

2534
/**
26-
* Alternative name or alias of the waifu.
35+
* The last name of the Waifu.
2736
* @type {String}
2837
*/
29-
alt: { type: String },
30-
},
31-
from: {
38+
last: { type: String, required: true },
39+
3240
/**
33-
* The name of the source or origin of the waifu.
41+
* The full name of the Waifu.
3442
* @type {String}
3543
*/
36-
name: { type: String },
44+
full: { type: String, required: true },
3745

3846
/**
39-
* The type or category of the source from which the waifu originates.
47+
* The native name of the Waifu.
4048
* @type {String}
4149
*/
42-
type: { type: String },
50+
native: String,
51+
52+
/**
53+
* The user-preferred name of the Waifu.
54+
* @type {String}
55+
*/
56+
userPreferred: { type: String, required: true },
4357
},
58+
4459
/**
45-
* Array of image URLs associated with the waifu.
46-
* @type {Array}
60+
* The image URL associated with the Waifu.
61+
* @type {Object}
4762
*/
48-
images: [String],
49-
50-
statistics: {
63+
image: {
5164
/**
52-
* The number of favorites received by the waifu.
53-
* @type {Number}
65+
* The URL for the large image.
66+
* @type {String}
5467
*/
55-
fav: { type: Number },
68+
large: String,
69+
medium: String,
70+
},
5671

72+
/**
73+
* The number of favorites for the Waifu.
74+
* @type {Number}
75+
*/
76+
favourites: { type: Number, required: true },
77+
78+
/**
79+
* The URL of the Waifu's profile.
80+
* @type {String}
81+
*/
82+
siteUrl: { type: String, required: true },
83+
84+
/**
85+
* The description of the Waifu.
86+
* @type {String}
87+
*/
88+
description: { type: String, required: true },
89+
90+
/**
91+
* The age range of the Waifu.
92+
* @type {String}
93+
*/
94+
age: String,
95+
96+
/**
97+
* The gender of the Waifu.
98+
* @type {String}
99+
*/
100+
gender: { type: String, required: true },
101+
102+
/**
103+
* The blood type of the Waifu.
104+
* @type {String}
105+
*/
106+
bloodType: String,
107+
108+
/**
109+
* The date of birth of the Waifu.
110+
* @type {Object}
111+
*/
112+
dateOfBirth: {
57113
/**
58-
* The number of times the waifu is loved.
114+
* The year of birth.
59115
* @type {Number}
60116
*/
61-
love: { type: Number },
117+
year: Number,
62118

63119
/**
64-
* The number of times the waifu is disliked or hated.
120+
* The month of birth.
65121
* @type {Number}
66122
*/
67-
hate: { type: Number },
123+
month: Number,
68124

69125
/**
70-
* The number of upvotes received by the waifu.
126+
* The day of birth.
71127
* @type {Number}
72128
*/
73-
upvote: { type: Number },
129+
day: Number,
130+
},
74131

132+
/**
133+
* The media information associated with the Waifu.
134+
* @type {Object}
135+
*/
136+
media: {
75137
/**
76-
* The number of downvotes received by the waifu.
77-
* @type {Number}
138+
* The list of media nodes.
139+
* @type {Array}
78140
*/
79-
downvote: { type: Number },
141+
nodes: [
142+
{
143+
/**
144+
* The unique identifier for the media.
145+
* @type {Number}
146+
*/
147+
id: { type: Number, required: true },
148+
149+
/**
150+
* The unique identifier for the media on MyAnimeList.
151+
* @type {Number}
152+
*/
153+
idMal: { type: Number, required: true },
154+
155+
/**
156+
* The cover image URL for the media (medium size).
157+
* @type {Object}
158+
*/
159+
coverImage: {
160+
medium: { type: String, required: true },
161+
},
162+
163+
/**
164+
* The banner image URL for the media.
165+
* @type {String}
166+
*/
167+
bannerImage: String,
168+
169+
/**
170+
* The title information for the media.
171+
* @type {Object}
172+
*/
173+
title: {
174+
/**
175+
* The romaji title of the media.
176+
* @type {String}
177+
*/
178+
romaji: { type: String, required: true },
179+
180+
/**
181+
* The English title of the media.
182+
* @type {String}
183+
*/
184+
english: { type: String, required: true },
185+
186+
/**
187+
* The native title of the media.
188+
* @type {String}
189+
*/
190+
native: { type: String, required: true },
191+
192+
/**
193+
* The user-preferred title of the media.
194+
* @type {String}
195+
*/
196+
userPreferred: { type: String, required: true },
197+
},
198+
199+
/**
200+
* The list of synonyms for the media title.
201+
* @type {Array}
202+
*/
203+
synonyms: [String],
204+
205+
/**
206+
* The popularity rank of the media.
207+
* @type {Number}
208+
*/
209+
popularity: Number,
210+
211+
/**
212+
* The type of the media (e.g., ANIME, MANGA).
213+
* @type {String}
214+
*/
215+
type: { type: String, required: true },
216+
217+
/**
218+
* The format of the media (e.g., TV, MOVIE).
219+
* @type {String}
220+
*/
221+
format: { type: String, required: true },
222+
},
223+
],
80224
},
81225
});
82226

0 commit comments

Comments
 (0)