@riffyh/database 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -0
- package/dist/index.mjs +102 -0
- package/package.json +30 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import mongoose, { Document } from "mongoose";
|
|
2
|
+
import { Gallery } from "@riffyh/commons";
|
|
3
|
+
|
|
4
|
+
//#region src/models/gallery.d.ts
|
|
5
|
+
interface GalleryDocument extends Gallery, Document {
|
|
6
|
+
id: string;
|
|
7
|
+
}
|
|
8
|
+
declare const GalleryModel: mongoose.Model<any, {}, {}, {}, any, any>;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { GalleryDocument, GalleryModel };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import mongoose, { Schema } from "mongoose";
|
|
2
|
+
import { TagType } from "@riffyh/commons";
|
|
3
|
+
//#region src/models/gallery.ts
|
|
4
|
+
const ImageSchema = new Schema({
|
|
5
|
+
src: {
|
|
6
|
+
type: String,
|
|
7
|
+
required: true
|
|
8
|
+
},
|
|
9
|
+
width: {
|
|
10
|
+
type: Number,
|
|
11
|
+
required: true
|
|
12
|
+
},
|
|
13
|
+
height: {
|
|
14
|
+
type: Number,
|
|
15
|
+
required: true
|
|
16
|
+
}
|
|
17
|
+
}, { _id: false });
|
|
18
|
+
const OrderedImageSchema = new Schema({
|
|
19
|
+
src: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
width: {
|
|
24
|
+
type: Number,
|
|
25
|
+
required: true
|
|
26
|
+
},
|
|
27
|
+
height: {
|
|
28
|
+
type: Number,
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
order: {
|
|
32
|
+
type: Number,
|
|
33
|
+
required: true
|
|
34
|
+
}
|
|
35
|
+
}, { _id: false });
|
|
36
|
+
const TagSchema = new Schema({
|
|
37
|
+
id: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
key: {
|
|
42
|
+
type: String,
|
|
43
|
+
required: true
|
|
44
|
+
},
|
|
45
|
+
slug: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true
|
|
48
|
+
},
|
|
49
|
+
name: {
|
|
50
|
+
type: String,
|
|
51
|
+
required: true
|
|
52
|
+
},
|
|
53
|
+
type: {
|
|
54
|
+
type: String,
|
|
55
|
+
enum: Object.values(TagType),
|
|
56
|
+
required: true
|
|
57
|
+
}
|
|
58
|
+
}, { _id: false });
|
|
59
|
+
const GallerySchema = new Schema({
|
|
60
|
+
id: {
|
|
61
|
+
type: String,
|
|
62
|
+
required: true
|
|
63
|
+
},
|
|
64
|
+
key: {
|
|
65
|
+
type: String,
|
|
66
|
+
required: true
|
|
67
|
+
},
|
|
68
|
+
title: {
|
|
69
|
+
display: {
|
|
70
|
+
type: String,
|
|
71
|
+
required: true
|
|
72
|
+
},
|
|
73
|
+
original: {
|
|
74
|
+
type: String,
|
|
75
|
+
default: null
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
cover: {
|
|
79
|
+
type: ImageSchema,
|
|
80
|
+
required: true
|
|
81
|
+
},
|
|
82
|
+
pages: {
|
|
83
|
+
type: [OrderedImageSchema],
|
|
84
|
+
required: true
|
|
85
|
+
},
|
|
86
|
+
tags: {
|
|
87
|
+
type: [TagSchema],
|
|
88
|
+
required: true
|
|
89
|
+
}
|
|
90
|
+
}, { timestamps: true });
|
|
91
|
+
GallerySchema.index({
|
|
92
|
+
id: 1,
|
|
93
|
+
key: 1
|
|
94
|
+
}, { unique: true });
|
|
95
|
+
GallerySchema.index({
|
|
96
|
+
"title.display": "text",
|
|
97
|
+
"tags.name": "text"
|
|
98
|
+
});
|
|
99
|
+
GallerySchema.index({ createdAt: -1 });
|
|
100
|
+
const GalleryModel = mongoose.models.Gallery || mongoose.model("Gallery", GallerySchema);
|
|
101
|
+
//#endregion
|
|
102
|
+
export { GalleryModel };
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@riffyh/database",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/rayriffy/rayriffy-h.git"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"dist/"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/index.mjs",
|
|
13
|
+
"types": "dist/index.d.mts",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"registry": "https://registry.npmjs.org"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"mongoose": "8.9.5",
|
|
20
|
+
"@riffyh/commons": "2.1.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/mongoose": "5.11.97",
|
|
24
|
+
"tsdown": "0.21.7"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"dev": "tsdown --watch",
|
|
28
|
+
"build": "tsdown"
|
|
29
|
+
}
|
|
30
|
+
}
|